ExtJS: add checkbox column "on-the-fly"
I have a custom 'class' which extends Ext.grid.GridPanel. I would like to have a column of checkboxes (example which uses Ext.ux.grid.CheckboxColumn - just the thing i need). My goal is to use it with pre-generated configuration object, including column model (it's generated by a PHP script), so I overloaded initComponent method to add column inside it:
MyGrid = Ext.extend
(
Ext.grid.GridPanel
,{
initComponent : function()
{
this.columns.push({
xtype : 'checkcolumn'
,header : 'Show on map ?'
,dataIndex : 'showonmap'
,width : 130
});
Ext.apply(this, {columns:this.columns});
MyGrid.superclass.initComponent.apply(this, arguments);
}
}
);
Such thing worked with ActionColumn component, but this code fails, because 开发者_Go百科it can't find constructor (probably for CheckColumn).
How should I modify my code or CheckColumn to make this thing work?
Thanks in advance!
If the constructor can't be found, you must not have imported the CheckColumn class properly. Try this to see if the constructor can be found directly:
MyGrid = Ext.extend
(
Ext.grid.GridPanel
,{
initComponent : function()
{
this.columns.push(new Ext.ux.grid.CheckColumn({
,header : 'Show on map ?'
,dataIndex : 'showonmap'
,width : 130
}));
Ext.apply(this, {columns:this.columns});
MyGrid.superclass.initComponent.apply(this, arguments);
}
}
);
If you get an exception that Ext.ux.grid.CheckColumn is not a constructor
, then you know for sure the classes isn't avaiable. Make sure that you have included the class properly, and you can verify using Firebug that the source was actually included and is available.
精彩评论