Programmatically change an EditorGrid's cell value

Posted by Snowright on Stack Overflow See other posts from Stack Overflow or by Snowright
Published on 2010-03-03T20:49:14Z Indexed on 2010/03/13 18:45 UTC
Read the original article Hit count: 292

Filed under:
|
|

Hi,

I have an Editor Grid where if a specific cell is in focus (is being edited), a window containing a tree panel pops up allowing the user to choose a node from the treepanel as the new value of the cell. This way, the user isn't actually editing the cell in question, but is using the window to choose the new value. However, I am having difficulties setting the value of the cell in question programmatically.

Below is the code I use to set the grid up, including the column model that chooses what editor to use for a cell depending on the value type:

var editorCM = new Ext.grid.ColumnModel({
  //config
  ,editors : {
    //rest of editors
    'id' : new Ext.grid.GridEditor(new Ext.form.TextField({readOnly : true}))
  }
  ,getCellEditor : function(col, row) {
    //choose editor depending on the type value of a cell
  }
})

var editorGrid = new Ext.grid.EditorGridPanel({
  //rest of config
  ,cm : editorCM
})

Below is my code to change the cell's value once the user chooses from the treepanel.

function submitNode(newValue) {
  var temp = editorGrid.GetSelectionModel().getSelectedCell(); //returns array containing column and row position of selected cell, which value we want to change.

  //temp[1] = column index, temp[0] = row index
  //Gets the cell editor at specific position and sets new value for that cell
  editorGrid.getColumnModel().getCellEditor(temp[1], temp[0]).setValue(newValue);
}

I've also tried a few other ways (all including setValue(newValue)), but have come up empty handed. I've looked through the API and the ExtJS forums for any clue but have also come up empty handed.

© Stack Overflow or respective owner

Related posts about extjs

Related posts about JavaScript