问题
I have to append a value to the data fetched from the store before rendering it to the grid in ExtJs.
Please guide me on achieving the above mentioned functionality.
Currently the grid is populated in the following manner:
Ext.define("MyApp.view.ShowDetails",{
extend: 'Ext.grid.Panel',
requires:['MyApp.store.MyStore'],
store:'MyStore',
stateId: 'stateGrid',
selType : 'checkboxmodel',
selModel : {
mode : 'MULTI'
},
plugins : [Ext.create('Ext.grid.plugin.RowEditing', {
clicksToEdit : 2
})],
defaultType: 'textfield',
columns: [
{
header: 'Userid',
width: 150,
dataIndex: 'uid',
editor :
{
allowBlank : true
}
},
...
回答1:
Yes this is possible,using the convert
property in field declaration in MODEL
An Example:
{
name: 'uid',
type: 'string',
convert: function (value, record) {
if (!value)
return value+'D';
else
return value;
}
},
来源:https://stackoverflow.com/questions/36262664/how-to-modify-fields-before-rendering-it-to-the-grid-in-extjs