• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

[SOLVED] grid colum setEditor why not working ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [SOLVED] grid colum setEditor why not working ?

    Hi, i have a issue with a dynamic editable grid, for which i want to set the edit property dynamically

    therefore i've been playing around with the shipped valence 3.2 example (editable grid) and the debug functions in chrome to see how it should/could be done..



    when i do the following in the google debugger:

    Code:
    gr = Ext.ComponentQuery.query('grid')[0]
    ->i get the grid definition object
    Code:
    gc= gr.getView().getGridColums()
    -> returns an array containing all grid colums
    Code:
    ge = gc[3].getEditor()
    -> i assume this is returning me the editor field for the 4th column of the grid

    if i then do :
    Code:
    gc[3].setEditor(null)
    -> field on the grid is no longer editable

    and afterwards want to restore the editing =
    Code:
    gc[3].setEditor(ge)
    -> says 'undefined' where i expect it to restore to the editor values???

    can anyone help me out on this?

    thx

    thierry

  • #2
    Thierry,

    You can set an editor on a column by passing the editor config.

    Example

    Code:
           gc[3].setEditor({
               xtype: 'textfield',
               allowBlank: false
            });

    Comment


    • #3
      Are you asking how the default value of the control is set to zero, but your editor is dynamically changing?

      In a column configuration, you probably want to override the getEditor function so that it returns an editor. To have no editor, you can return false.

      The getEditor function gets a parameter that is the row record, so perhaps you can set that as the value when you are creating a new config?

      http://docs.sencha.com/extjs/4.2.2/#...thod-getEditor

      Here is an example of code I wrote which uses different editors for different data types. One specific note, is see how the getEditor function expects you to return a field wrapped in a grid cell editor:

      Code:
      return Ext.create('Ext.grid.CellEditor', {
          field: newControl
      });

      Code:
      
      
      getEditor : function(record, dflt) {
              var me = this.up('.grid');
              var fieldRec, newControl;
              var fieldStore = me.fieldStore;
              var ix = fieldStore.findExact('FLDID', record.get('FLDID'));
              var type = record.get('EQLMODE');
              
              if (type === 'V' || type === 'L') {
                      
                  if (....) {
                      //removed code which looks for a field config 
                      // record in a store and creates an object 
                      // configuration if it finds one.
                      // see syntax below.
                  } else {   
                      return dflt;
          	    }
              } else if (type === 'P') {
                  newControl = {
                      xtype : 'combo',
                      store : app.getStore('parameters'),
                      displayField : 'PROMPTTXT',
                      valueField : 'PARMALIAS',
                      queryMode : 'local',
                      triggerAction : 'all',
                      listeners : {
                          select : function(combo, records) {
                              if (records.length > 0) {
                                  combo.next('#EQLPRMDSC').setValue(records[0].get('FIELDDESC'));    
                              }
                          }
                      }
                  };
                  
                  return Ext.create('Ext.grid.CellEditor', {
                      field: newControl
                  });
              } else if (type === 'F') {
                  newControl = {
                      xtype : 'combo',
                      store : app.getStore('columns'),
                      displayField : 'FIELDDESC',
                      valueField : 'FLDID',
                      queryMode : 'local',
                      triggerAction : 'query',
                      flex : 1
                  };
                  
                  return Ext.create('Ext.grid.CellEditor', {
                      field: newControl
                  });
              } else {
                  return dflt;
              }
                  
          }

      Comment


      • #4
        Hi, Johnny

        i've tried this in the example above, but i still get the same error : 'undefined'

        Comment


        • #5
          Below is a screenshot of my console when viewing the Editor Grid (delayed) example.

          Successfully removing and adding an editor.

          Screen Shot 2014-01-28 at 11.17.16 AM.png

          Comment

          Working...
          X