PDA

View Full Version : call a different renderer function after cell is edited



niks86
8 Mar 2008, 3:16 AM
hi,
Am pretty new to extjs.i would like to know how i could call a different renderer function after a cell is edited in the EditorGrid.
Could somebody please help me with this!!:s



Ext.grid.DynamicColumnModel = function(store){
var cols = [];
var recordType = store.recordType;
var fields = recordType.prototype.fields;

for (var i = 0; i < fields.keys.length; i++)
{
var fieldName = fields.keys[i];
var field = recordType.getField(fieldName);
cols[i] = {header: field.name, dataIndex: field.name, width:100,
editor: new fm.TextField({
allowBlank: true
})};
}
Ext.grid.DynamicColumnModel.superclass.constructor.call(this, cols);
};

Ext.extend(Ext.grid.DynamicColumnModel, Ext.grid.ColumnModel, {});


this is my afteredit function:


function afterEdit(grid1){

console.log('after edit!!');

this.grid=grid1;

var ed=cm.getCellEditor(0,0);

var val=ed.getValue();

var value= Ext.encode(val);
var req = Ext.Ajax.request({

method:'POST',
url: "try.jsp",
disableCaching: false,

params:value,


callback:function(options,success,response){
if(success){
console.log('req sent!');

}
},
failure:function(response,options){
console.log(response.responseText);
}
});

alert(value);


}




this is the renderer i want to call after the cell is edited:


function change_font(grid){

console.log('inside renderer');
this.grid=grid;

var ed=cm.getCellEditor(0,0);

var val=ed.getValue();

return '<span style='+fnt_wt+';'+fnt_style+';'+fnt_family+';'+fnt_size+';'+bk_color+';'+fnt_color+'>'+val+'</span>';


}

Condor
8 Mar 2008, 3:26 AM
EditorGridPanel already applies the x-grid3-dirty-cell class to the cell if the record is dirty and the field is modified.
Couldn't you just create a CSS rule that changes the way a cell looks if x-grid3-dirty-cell is on the TD?

ps. You can find out if a field is modified in the renderer by using:


renderer: function(value, meta, record, row, col, store) {
var field = store.getColumnMode().getDataIndex(col);
if (record.dirty && typeof record.modified[field] !== 'undefined') {
return '<span style="color:red;">' + value + </span>';
}
return value;
}

niks86
8 Mar 2008, 5:16 AM
Thanx a lot,Condor!!!!:)It worked!!:)