1. #21
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    You can use editors in multiple grids (but cleanup on destroy might fail - untested).

    1. Create your editors as Ext.grid.GridEditor instances and not as Ext.form.Fields.
    2. getEditorParent needs to return an element that both grids share (e.g. Ext.getBody()).

  2. #22
    Sencha User
    Join Date
    Sep 2009
    Posts
    112
    Vote Rating
    0
    asagala is on a distinguished road

      0  

    Default


    In the case were my dynamic editor has a combobox (enumCombo). How can I specify a dynamic renderer for the column only when the editor is the combobox?

    Code:
              editors: {
                'varchar': new Ext.grid.GridEditor(new Ext.form.TextField({})),
                'int': new Ext.grid.GridEditor(new Ext.form.NumberField({})),
                'enum(\'Active\',\'Inactive\')': new Ext.grid.GridEditor(enumCombo),
                'timestamp': new Ext.grid.GridEditor(new Ext.form.DateField({}))
              }

  3. #23
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    You will need to write a renderer that also calls getCellEditor to find out if the used editor is a combobox and returns the appropriate item from it's store.

  4. #24
    Sencha User
    Join Date
    Sep 2009
    Posts
    112
    Vote Rating
    0
    asagala is on a distinguished road

      0  

    Default


    Still very new to Extjs so thanks for taking the time to help me.

    So if my cell Editor is this:

    Code:
              getCellEditor: function(colIndex, rowIndex) {
                 var field = this.getDataIndex(colIndex);
                if (field == 'Value') {
                    var rec = store.getAt(rowIndex);
                    var storeRec = fieldCombo.getStore().getById(rec.get('Field'));
                    
                    // need to get the type associated to the value in the combbo. The type determines the editor used
                    return this.editors[storeRec.get('type')];
                }
                return Ext.grid.ColumnModel.prototype.getCellEditor.call(this, colIndex, rowIndex);
              },
    and I want to create a new renderer how do I get the rowIndex and colIndex from inside my renderer function so that I can pass it to getCellEditor function

    Code:
            Ext.util.Format.valueRenderer = function(){
                return function(value){
                    
    
                    // MY issue
                    editor = cm.getCellEditor(colIndex, rowIndex);
                    // once I have the editor type then I fetch the right value from the combo       store  and return it
                    //var record = combo.findRecord(combo.valueField, value);
                    return the right value from combo box;
                }
            }
    Also how do I test if editor is a combobox. typeof only return Object and not the type

  5. #25
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    1. A renderer has a lot more parameters (including colIndex and rowIndex).
    2. You can test if the field (property of editor) contains any of the combobox methods (e.g. findRecord).

  6. #26
    Sencha User
    Join Date
    Sep 2009
    Posts
    112
    Vote Rating
    0
    asagala is on a distinguished road

      0  

    Default


    Sorry didnt think renderer had more params. Its hard to find stuff in the documentation when you are not sure what to look for . For your second point I understand what you mean but dont really know how to do it in Extjs. If I try do something like this

    Code:
                    if(editor){
                        if(editor.field.findRecord(value))
                            alert('blah');
                    }
    it works but gives an error if not defined. I do you catch that error in Extjs?

  7. #27
    Sencha User
    Join Date
    Sep 2009
    Posts
    112
    Vote Rating
    0
    asagala is on a distinguished road

      0  

    Default


    Here is what I tried

    Code:
            Ext.util.Format.valueRenderer = function(enumCombo){
                return function(value, metadata ,record, colIndex , rowIndex, store){
                    
                    var editor = cm.getCellEditor(colIndex, rowIndex);
    
                    try{
                        if(editor){
                            if(editor.field.findRecord(value)){
                                var record = enumCombo.findRecord(enumCombo.valueField, value);
                                return record ? record.get(enumCombo.displayField) : enumCombo.valueNotFoundText;
                            }
                        }
                    }
                    catch(e){
                        return value;
                    }
    
                }
            }
    Doestn really work. Seem the try/catch still causes an error to occur

  8. #28
    Sencha User
    Join Date
    Sep 2009
    Posts
    112
    Vote Rating
    0
    asagala is on a distinguished road

      0  

    Default


    Got it working using this code but still generates an error in firebug.

    Code:
            Ext.util.Format.valueRenderer = function(enumCombo){
                return function(value, metadata ,record, rowIndex , colIndex, store){
                    
                    // if column is value column
                    if(colIndex == 4){
                        var editor = cm.getCellEditor(colIndex, rowIndex);
    
                        try{
                            if(editor){
                                if(editor.field.findRecord(value)){
                                    var record = enumCombo.findRecord(enumCombo.valueField, value);
                                    return record ? record.get(enumCombo.displayField) : enumCombo.valueNotFoundText;
                                }
                            }
                            else
                                return value;
                        }
                        catch(e){
                            return value;
                        }
                    }
                    else{
                        return value;
                    }
                }
            }

  9. #29
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    It's:
    Code:
    Ext.util.Format.valueRenderer = function(enumCombo){
        return function(value, metadata, record, rowIndex, colIndex, store){
            var editor = cm.getCellEditor(colIndex, rowIndex),
                field = editor ? editor.field : null;
            if(field && field.findRecord){
                var record = field.findRecord(field.valueField, value);
                return record ? record.get(field.displayField) : field.valueNotFoundText;
            }
            return value;
        }
    };

  10. #30
    Ext User
    Join Date
    Mar 2008
    Posts
    57
    Vote Rating
    0
    aleczapka is on a distinguished road

      0  

    Default


    And Condor saved the day once again!

    Thx a lot!

    /bows

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar