1. #31
    Ext User
    Join Date
    Apr 2008
    Posts
    26
    Vote Rating
    0
    raviext is on a distinguished road

      0  

    Default


    Hi Saki & MJ

    Thanks a lot for the information. I will go through these tuturials starting today.

    ~Rave

  2. #32
    Ext User
    Join Date
    Aug 2007
    Posts
    17
    Vote Rating
    1
    wolf is on a distinguished road

      0  

    Default GridValidator within FormPanel using monitorResize

    GridValidator within FormPanel using monitorResize


    Back to the GridValidator

    I changed the isCellValid function so that it ignores a currently focused field in the grid. Otherwise the line within the "if" clears out any typed in value. I am catching the "clientvalidation" event in FormPanel and using FormPanel's monitorResize (gray out submit button until valid). I extended both FormPanel and GridValidator. The code below could not be extended. I'll give more details if anyone has interest.
    PHP Code:
               isCellValid:function(colrow) {
                    if(!
    this.colModel.isCellEditable(colrow)) {
                        return 
    true;
                    }
                    var 
    ed this.colModel.getCellEditor(colrow);
                    if(!
    ed) {
                        return 
    true;
                    }
                    var 
    record this.store.getAt(row);
                    if(!
    record) {
                        return 
    true;
                    }
                    var 
    field this.colModel.getDataIndex(col);
    var 
    isValid false// if hasFocus, assume not yet valid
    if ( !ed.field.hasFocus ) {
                    
    ed.field.setValue(record.data[field]);
                    
    isValid ed.field.isValid(true);
    }
                    return 
    isValid;
                } 
    // end of function isCellValid 

  3. #33
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    Quote Originally Posted by wolf View Post
    and using FormPanel's monitorResize (gray out submit button until valid).
    Do you mean monitorValid?

    Quote Originally Posted by wolf View Post
    The code below could not be extended.
    I don't understand that comment?

    Quote Originally Posted by wolf View Post
    I'll give more details if anyone has interest.
    Sure, post what you got. Any criticism only helps everyone?

  4. #34
    Sencha User
    Join Date
    Oct 2008
    Posts
    7
    Vote Rating
    0
    mestrona is on a distinguished road

      0  

    Default


    i added "validateModifiedOnly" for those who want check editet fields only:
    PHP Code:
    /**
     * EditorGrid validation plugin
     * Adds validation functions to the grid
     *
     * @author  Jozef Sakalos, aka Saki
     * @version 0.1
     *
     * Usage: 
     * grid = new Ext.grid.EditorGrid({plugins:new Ext.ux.plugins.GridValidator(), ...})
     */
    Ext.ux.plugins.GridValidator = function(config) {

        
    // initialize plugin
        
    this.init = function(grid) {
            
    Ext.apply(grid, {
                
    /**
                 * Checks if a grid cell is valid
                 * @param {Integer} col Cell column index
                 * @param {Integer} row Cell row index
                 * @param {Boolean} validateModifiedOnly true to validate modified fields only
                 * @return {Boolean} true = valid, false = invalid
                 */
                
    isCellValid:function(colrowvalidateModifiedOnly) {
                    if(!
    this.colModel.isCellEditable(colrow)) {
                        return 
    true;
                    }
                    var 
    ed this.colModel.getCellEditor(colrow);
                    if(!
    ed) {
                        return 
    true;
                    }
                    var 
    record this.store.getAt(row);
                    if(!
    record) {
                        return 
    true;
                    }
                    var 
    field this.colModel.getDataIndex(col);
                    if(!
    record.isModified(field)) {
                        return 
    true;
                    }
                    
    ed.field.setValue(record.data[field]);
                    return 
    ed.field.isValid(true);
                } 
    // end of function isCellValid

                /**
                 * Checks if grid has valid data
                 * @param {Boolean} editInvalid true to automatically start editing of the first invalid cell
                 * @param {Boolean} validateModifiedOnly true to validate modified fields only
                 * @return {Boolean} true = valid, false = invalid
                 */
                
    ,isValid:function(editInvalidvalidateModifiedOnly) {
                    var 
    cols this.colModel.getColumnCount();
                    var 
    rows this.store.getCount();
                    var 
    rc;
                    var 
    valid true;
                    for(
    0rowsr++) {
                        for(
    0colsc++) {
                            
    valid this.isCellValid(crvalidateModifiedOnly);
                            if(!
    valid) {
                                break;
                            }
                        }
                        if(!
    valid) {
                            break;
                        }
                    }
                    if(
    editInvalid && !valid) {
                        
    this.startEditing(rc);
                    }
                    return 
    valid;
                } 
    // end of function isValid
            
    });
        }; 
    // end of function init
    }; // GridValidator plugin end 

  5. #35
    Sencha User
    Join Date
    Jun 2012
    Posts
    2
    Vote Rating
    0
    rameshP87 is on a distinguished road

      0  

    Default How can i use in my code?

    How can i use in my code?


    any one please help me.

  6. #36
    Sencha User
    Join Date
    Jun 2012
    Posts
    2
    Vote Rating
    0
    rameshP87 is on a distinguished road

      0  

    Default how can i use this code ?

    how can i use this code ?


    Can i use this file as separate file ?