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

隐身守侯 提交于 2019-12-12 04:07:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!