anastsiacrs
anastsiacrs

Reputation: 159

ExtJS 6. Adding column to grid

I want to add additional column to grid dynamically on table instantiation. So, I've added process function to gridPanel with following section

   var clmn = {
                xtype: 'checkcolumn',
                dataIndex: 'test,
                editor: {
                    xtype: 'checkboxfield'
                }
            };
   config.columns.push(clmn);

As you can see, rowediting plugin is used here too.

Actually column is added and displayed on screen. But it is not hold correct data that has been loaded, only defaultValue from model.

On row modification (when rowediting plugin is started) real data is displayed.

What is the issue here? May be there is some refresh method that should be used to refresh metadata or sth like this..

Please, take into consideration that i am working via Sencha Architect

Upvotes: 1

Views: 3176

Answers (1)

Umut
Umut

Reputation: 176

columns.push() is not proper way to do this. So you should use reconfigure method which is mentioned here. If your store is already have fields for new columns you don't have to pass it again. Just get your current columns and add your new columns and reconfigure the grid.

edit for answer : Your problem easer than before. you can just pass your columns to it like below;

var yourGenericColumns = [
                     {text: 'First Name',  dataIndex:'firstname'},
                    {text: 'Last Name',  dataIndex:'lastname'}];

yourGenericColumns.push({text : 'Age', dataIndex: 'age'});

Ext.create('YourApp.YourCustomGrid',{
     columns : yourGenericColumns
});

Upvotes: 1

Related Questions