PDA

View Full Version : How do I add a listener to a CheckColumn?



dkgemini
7 Sep 2011, 6:04 AM
Hi there

I am using a CheckColumn (plugin) in an EditorGridPanel. It updates fine with the info from my database (i.e. it shows checked/unchecked depending on the values 1 or 0 in the database). The problem comes when I check or uncheck the checkbox - the change doesn't get updated in the database. Changes to the other fields work just fine, it is just the checkbox that I can't seem to make work.

I have a feeling I have to use a different listener than afteredit (checkchange probably), but I can't figure out how.

I hope someone can help me.

Here's a some of my code, hopefully someone can help me - I am very green when it comes to Ext JS.


var checkColumn = new Ext.grid.CheckColumn({
header: 'State funded',
dataIndex: 'is_state_funded',
width: 100,
});

var grid = new Ext.grid.EditorGridPanel({

.. code left out ...

columns: [
{header: "ID", dataIndex: 'id', id: 'id', width: 35},
{header: "School Name", dataIndex: 'school_name', id: 'school_name', editor: school_name_edit, width: 220},
{header: "School Type", dataIndex: 'school_type', renderer: school_type_name, editor: school_type_edit, width:100},
checkColumn
],
}),
sm: new Ext.grid.RowSelectionModel({
singleSelect: true
}),
listeners: {
afteredit: function(e){
Ext.Ajax.request({
url: 'schools-update.php',
params: {
action: 'update',
id: e.record.id,
field: e.field,
value: e.value
},
success: function(resp,opt) {
e.record.commit();
},
failure: function(resp,opt) {
e.record.reject();
}
});
}
},

... code left out ...

Ash2009
20 Sep 2011, 1:41 PM
the listener onMouseDown is already added to the Ext.grid.CheckColumn class.check/uncheck is handled there.

dkgemini
22 Sep 2011, 3:11 AM
Thanks for that. I am still not sure how to do that... I ended up solving the problem in a different way.

mounir1
12 Apr 2018, 12:31 AM
this thread is so old but this is how I handled it :) Extjs6.5

2fhq