Search code examples
extjsextjs4extjs4.1extjs4.2extjs3

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


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
                }

              }, 
             ...

Solution

  • 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;
    
                }
            },