PDA

View Full Version : RowEditor plugin and non-editable rendered fields



Izhaki
12 Jan 2010, 8:22 PM
Hi,

Unless I'm missing something, I believe there is an issue with the RowEditor plugin.

Say that all my grid columns use renderers. But some of the columns cannot be edited.

When RowEditor shows, it takes into no account the renderer, so fields that cannot be edited are simply shown with the original record value (I'm using hash stores, so I see the index, eg '12', instead of the actual value, eg 'Room 1').

The following code fixes this, but I reckon this should actually be applied to the extension itself:



var editor = new Ext.ux.grid.RowEditor({
saveText: 'Update',
renderedValue : function(val, field){
var renderer = this.grid.getColumnModel().getColumnsBy(function(col){
return col.dataIndex == field;
})[0].renderer;
return renderer(val);
},
preEditValue : function(r, field){
var value = this.renderedValue(r.data[field], field);
return this.autoEncode && typeof value === 'string' ? Ext.util.Format.htmlDecode(value) : value;
},
postEditValue : function(value, originalValue, r, field){
if (this.renderedValue(originalValue, field) == value)
value = originalValue;
return this.autoEncode && typeof value == 'string' ? Ext.util.Format.htmlEncode(value) : value;
},
});

terminal8
8 Feb 2010, 3:18 AM
+1 to this and thanks for sharing the code!