PDA

View Full Version : TreeGrid change events of specific cells



papouuu
10 Apr 2013, 4:23 AM
Hello,

I've search into documentation and forum for a while but didn't found an example or a thread corresponding to my needs.

In fact i have a TreeGrid with a text column and 3 checkcolumns. I would like to enable or disable others checkbox in same raw i clicked.
i have this function in my processevent property of my column:


processEvent: function (name, e, grid, rowIndex, colIndex) {
if (name == 'mousedown') {
var record = e.store.getAt(rowIndex);
record.data.gest = !record.data.gest;
if (record.data.gest) {
record.data.mod = true;
record.data.pub = true;
}
e.store.reload();
e.panel.view.refresh();
}
}


So i can check or uncheck others checkbox but how to disable them only for this raw?

slemmon
12 Apr 2013, 8:51 AM
The processEvent method passes the record for the clicked checkbox/cell as a param:
( type, view, cell, recordIndex, cellIndex, e, record, row )

I suspect you'll need to inspect the record to see if the peer checkboxes in that same row/record are checked at the time you process the event.

papouuu
14 Apr 2013, 10:54 PM
Hi!! Thank You for reply!
Yes, your solution is wich one i have choosen, on clic on one of the 3 checkbox, i check or uncheck the others.
It can work as it and it's fine, but it could be better if i could disable click event dynamically.

slemmon
15 Apr 2013, 12:32 PM
You might be able to use beforeitemclick (http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.tree.Panel-event-beforeitemclick). You can return false from its handler and that will cancel the click event.

papouuu
15 Apr 2013, 11:48 PM
Yes, seems to be the right option too, but in fact I'm not able to access to others cells in the raw.
if i click on a cell in collumn 1 I want to disable click for same raw on collumn 2 and 3, and from collumn 1, how to access to cell 2 and 3 attributes?

slemmon
16 Apr 2013, 7:51 AM
The handler for the beforeitemclick event is passed the following parameters: ( this, record, item, index, e, eOpts)

So, in the handler you have access to the record for the row that was just clicked. You can evaluate the values of the fields in columns 1, 2, 3 and if they are checked (or any condition you want to evaluate for that cell/field) you can return true to allow the click or false to cancel it.