dcsimg
Results 1 to 1 of 1

Thread: Anyone using SlickGrid - look what I did!

  1. #1

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    CT
    Posts
    17,840

    Anyone using SlickGrid - look what I did!

    Anyone using SlickGrid - look at what I did here. I got a popup window that allows me to enter JavaScript code - three events of it - and they fire as you walk along the SlickGrid.

    If the screen shot it too small - here is the code from that window.

    Code:
    :onGridLoad
    
    this.gridWork( [ { 'sumCol': 'NewBudget', 'currentRow': -1, 'currentAmt': '0' }
                           , { 'append': '@NewBudget', 'text': 'Total Requested:  ', 'prefix': true }
                           , { 'bold': '@NewBudget' }
                           , { 'message': '@NewBudget' }
                           ] );
    
    :onBeforeCellEdit
    
    if (((item || {}).Existing || '') == 'Y') {
        errorMessage('Data can only be added!', 'New accounts can only be added.<br /><br />Existing accounts and those already saved must be changed by the Accounting office!<br /><br />Please enter new accounts on the blank line at the bottom of the grid.');
    }
    
    :onCellChange
    
    var d1='';
    var d2='';
    var d3='';
    var d4='';
    var numbers = /^[0-9]+$/;
    
    var strMsg='';
    
    if (currentCell == 1) {
        if (item.Account.length != 18) {
            strMsg = 'Account Numbers must be 18 characters in length';
        }
        if (strMsg.length == 0) {
            d1 = (item.Account.substr(2,1) || '');
            d2 = (item.Account.substr(4,1) || '');
            d3 = (item.Account.substr(10,1) || '');
            d4 = (item.Account.substr(15,1) || '');
            if ((d1 + d2 + d3 + d4) != '----') {
                strMsg = 'Account Numbers must be in the format ##-#-#####-####-##';
            }
        }
        if (strMsg.length == 0) {
            d1 = item.Account.substr(0,2) + item.Account.substr(3,1) + item.Account.substr(5,5) + item.Account.substr(11,4) + item.Account.substr(16,2);
            if (!d1.match(numbers)) {
                strMsg = 'Only enter numeric digits between the dashes in the format ##-#-#####-####-##';
            }
        }
    }
    
    if (strMsg.length != 0) {
            errorMessage('Bad Account',strMsg);
    }
    //alert('onCellChange');
    Attached Images Attached Images  

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width