如何在将字段呈现到 Extjs 中的网格之前修改字段

How to modify fields before rendering it to the grid in Extjs

在将数据呈现到 ExtJs 中的网格之前,我必须向从商店获取的数据附加一个值。

请指导我实现上述功能。

目前网格以下列方式填充:

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
                }

              }, 
             ...

是的,这是可能的,在 MODEL

的字段声明中使用 convert 属性

一个例子:

 {
            name: 'uid',
            type: 'string',
            convert: function (value, record) {
                if (!value)
                    return value+'D';
                else
                    return value;

            }
        },