Pratu
Pratu

Reputation: 11

Modify data before rendering to grid in ExtJS 4

How to modify the value stored in local storage before rendering it in the grid in ExtJs?

I need to pass the value to a function for processing before it gets rendered,

eg: process(value fetched from local storage);

I have written the Model like this:

Ext.define('MyApp.model.RegistrationModel', {
    extend: 'Ext.data.Model',
     fields: [
       { name: 'user', type: 'string' }, 
        { name: 'fName', type: 'string' },
        { name: 'lName', type: 'string' },
        { name: 'gender', type: 'string'},
        { name: 'role', type: 'string' },
        { name: 'phone', type: 'string'}

    ]
});

Upvotes: 0

Views: 1703

Answers (2)

Chandra Sekar
Chandra Sekar

Reputation: 312

You have to add renderer in grid columns you can render what ever you want:

{
 dataIndex: 'data',
      renderer: function (val, metaData, r) {
              return val + ' (' + "local data" + ')'; 
      },
}

Upvotes: 0

Milzer
Milzer

Reputation: 71

Do you want to modify the data just for visualisation? Then you can simply use the renderer config: http://docs.sencha.com/extjs/4.1.1/#!/api/Ext.grid.column.Column-cfg-renderer

Upvotes: 2

Related Questions