How to modify fields before rendering it to the gr

2019-09-01 02:30发布

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条回答
姐就是有狂的资本
2楼-- · 2019-09-01 03:28

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;

            }
        },
查看更多
登录 后发表回答