PDA

View Full Version : Grid Checkbox Column Listener



GoneIn20Seconds
5 Jul 2010, 3:50 PM
There is a example of an editor grid with a checkbox column that I'd like to copy. Here are the references:

Demo: http://www.sencha.com/deploy/dev/examples/ux/CheckColumn.js
Grid Checkbox Column: http://www.sencha.com/deploy/dev/examples/ux/CheckColumn.js

My only issue is that I want to add a listener that fires when the checkbox is checked/unchecked. This checkbox column plugin doesn't seem to support the regular listeners of a checkbox and I'm wondering if anyone knows how I could add a "check" listener.

Here is my code.



var store = new Ext.data.JsonStore({
url: "admin/ajax/store.php",
autoLoad: true,
autoDestroy: true,
fields: [
{ name: "id", type: "int" },
{ name: "checkbox", type: "bool" },
"value"
]
});

/****************************************************************************************************/
// This component comes from the CheckColumn class that I've copied from */
// http://www.sencha.com/deploy/dev/examples/ux/CheckColumn.js */
// I want to add the "check" listener to this component and have it call a function I specify. */
/****************************************************************************************************/
var checkbox = new Ext.grid.CheckColumn({
header: ' ',
dataIndex: 'checkbox',
width: 25

// this is what I'd like to add
, listeners: {
check: function(checkbox, checked) { ... }
}
});

var cm = new Ext.grid.ColumnModel({
defaults: {
sortable: false,
menuDisabled: true
},
columns: [
checkbox,
{ header: "Item", dataIndex: "value", id: "ColumnSimpleSelect" }
]
});

var grid = new Ext.grid.EditorGridPanel({
plugins: checkbox,
store: store,
cm: cm,
autoExpandColumn: "ColumnSimpleSelect"
});

Animal
5 Jul 2010, 9:33 PM
Column does not inherit from Observable right now.

This is something which I am pushing hard for being included in 3.3 onwards which will make things like CheckboxColumn MUCH easier.

I have code ready to contribute, I'm just waiting on the dev team to see if they want me to donate it.

GoneIn20Seconds
6 Jul 2010, 5:33 PM
Thanks for your help on this, Animal. I look forward to this functionality in version 3.3 if it's included. For now, anyone with this same problem can use the work around I found at http://www.sencha.com/forum/showthread.php?17580-Click-event-on-CheckColumn&p=446019. It's a very simple code replacement for the CheckboxColumn component found in the examples. Works perfectly in version 3.2 even though it was built for 2.x.

Animal
6 Jul 2010, 9:11 PM
Observable column code: http://www.sencha.com/forum/showthread.php?15107-OPEN-194-ColumnModel-to-handle-columnclick&p=379560#post379560