开发者

custom getCellEditor

开发者 https://www.devze.com 2023-02-13 11:24 出处:网络
I use custom CellEditor in my grid: getCellEditor: function(colIndex, rowIndex) { var field = this.getDataIndex(colIndex);

I use custom CellEditor in my grid:

getCellEditor: function(colIndex, rowIndex) {
    var field = this.getDataIndex(colIndex);
    if (field == 'value') {
    if ( type == 3 ) {
        return this.editors['number'];
    }   else if ( type == 1 ) {
        return this.editors['select'];
    }   else if ( t开发者_运维问答ype == 4 ) {
        return this.editors['checkbox'];
    }
    }
return Ext.grid.ColumnModel.prototype.getCellEditor.call(this, colIndex, rowIndex);
}
},this);

type - this is record.get('type') from grid.store. How to know type in this getCellEditor ? (I don't want to use global variable :) )


You can use the rowIndex parameter, so to access the 'type' for the current row in your grid:

grid.store.getAt(rowIndex).data.type


You will have need to have defined the type in the field definition, From there, you can use the row index to get the Record.

var record = store.getAt(rowIndex);
  for(var i = 0; i<record.fields.length; i++) {
    if(record.fields[i].name == 'Your Field')  {
      alert(record.fields[i].type);
    }
 }

This is untested but shows how you can test for the type of a given field in the record

0

精彩评论

暂无评论...
验证码 换一张
取 消