PDA

View Full Version : ExtJs 4.1: Grid: TextField Editor: Assign text "<SAMPLE>", shows blank cell



gaurav.varshikar
17 Oct 2013, 11:20 PM
Hi all,

I am facing this issue while using editors in grid.
And I am finding this in almost all the grid examples that I found on net.
In a grid having editor such as textfield, try entering a value like "<SAMPLE>".
Moment you go out of focus, a blank cell is displayed on the grid.
But if you again select it for editing, the actual entered text is retained.

Try it here: http://docs.sencha.com/extjs/4.0.7/#!/api/Ext.grid.plugin.CellEditing

I know this has to do with the html encoding/decoding and can be handled in the edit event.
But I feel this should have been handled internally by the grid.

Please suggest a better solution if any?

scottmartin
21 Oct 2013, 12:48 PM
Add a renderer to your column:



Ext.create('Ext.grid.Panel', {
title : 'Simpsons',
store : Ext.data.StoreManager.lookup('simpsonsStore'),
columns : [
{ header : 'Name', dataIndex : 'name', editor: { xtype: 'textfield' },

renderer : function(value) {
return Ext.htmlEncode(value); // display as entered instead of html
}
},
{ header : 'Email', dataIndex : 'email', flex : 1 },
{ header : 'Change', dataIndex : 'change' }
],
height : 200,
width : 400,

plugins: [ cellEditing ],

renderTo : Ext.getBody()
});