PDA

View Full Version : grid with checkcolumn



alex9311
18 Sep 2012, 2:43 PM
Hey all,

I'm trying to get a column of checkboxes in my grid, which read from a boolean value in the store. I've read over the documentation for checkcolumn (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.ux.CheckColumn) which seems to be what I need but I havn't gotten it to work properly. I'm using MVC architecture.

It works when I display the boolean store value in a regular column but crashes when I try to display the checkcolumn.

My grid view has:


Ext.define('AM.view.user.List' , {
extend: 'Ext.grid.Panel',
alias: 'widget.userlist',
store: 'Users',
height: 'auto',
width: 'auto',
autoFill: 'true',
layout: 'fit',
autoScroll: 'true',
initComponent: function() {
this.columns=[
{header: 'checktest', dataIndex: 'check', width: 40},
{header: 'First Name', dataIndex: 'FirstName', width: 75},
{header: 'Last Name', dataIndex: 'Last', width: 75},
//{xtype: 'checkcolumn', dataIndex: 'check', text: 'test', width: 50}
];
this.callParent(arguments);
}
});

my model looks like:


Ext.define('AM.model.User', {
extend: 'Ext.data.Model',
fields: [
{name: 'FirstName', type: 'string'},
{name: 'Last', type: 'string'},
{name: 'check', type: 'bool'}
],
});

and my store looks like:


Ext.define('AM.store.Users', {
extend: 'Ext.data.Store',
model: 'AM.model.User',
data: [
{FirstName: 'Alex', Last: 'Chandler', check: false}
{FirstName: 'Saul', Last: 'Griffin, check: true}
{FirstName: 'Rebecca', Last: 'Rose', check: false}
],
});


Thank you for any advice!

vietits
18 Sep 2012, 3:39 PM
You should load Ext.ux.CheckColumn before using it by using requires config:


Ext.define('AM.view.user.List' , {
extend: 'Ext.grid.Panel',
alias: 'widget.userlist',
requires: ['Ext.ux.CheckColumn'],
...



You also need to set path for Ext.ux namespace with Ext.Loader. Something likes this:


Ext.Loader.setConfig({
enabled: true, // enable dynamic loading of classes
paths: {
'Ext.ux': 'Path to Ext.ux folder',
...
}
});

alex9311
18 Sep 2012, 3:43 PM
thanks for the quick reply.

On the documentation it says "Note. As of ExtJS 3.3 this no longer has to be configured as a plugin of the GridPanel."
Isn't what you're describing configuring it as a plugin?

vietits
18 Sep 2012, 4:13 PM
In Ext 4, Ext.ux.CheckColumn is an extension that does not include with Ext framework.