PDA

View Full Version : column defaults



dotskeshav
24 Jul 2014, 10:00 PM
Hello,
I was creating GridPanel in below manner and working perfectly.


var userColumns = [
{header: "ID", width: 40, dataIndex: 'ID', sortable: true},
{header: "Name", width: 100, dataIndex: 'Name', sortable: true},
{header: "Email", width: 100, dataIndex: 'Email', sortable: true},
{header: "Status", width: 40, dataIndex: 'contactStatus', sortable: true},
];


var grid = new Ext.grid.GridPanel({
//store: campaignStore,
columns: userColumns,
renderTo:'rest-grid',
width:500,
height:500,
iconCls: 'icon-grid',
frame: true,
title: 'Grid Panel',
enableColumnHide: true,
tbar: [{
id: 'addBtn',
text: 'Add',
iconCls: 'silk-add'
}, '-', {
id: 'deleteBtn',
text: 'Delete',
iconCls: 'silk-delete'
}, '-'],
viewConfig: {
forceFit: true
}
});


Now I want to add defaults properties , see here (http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.grid.ColumnModel) for columns but without reconstructing the columns as

defaults: { sortable: true, menuDisabled: true, width: 100 },How to add Defaults inside Grid panel. Please suggest

slemmon
28 Jul 2014, 1:42 PM
When creating an Ext.grid.ColumnModel instance for the grid you can use the defaults config to pass default configurations to all columns.
http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.grid.ColumnModel-cfg-defaults
* see the top of the API doc page for an example