PDA

View Full Version : How to disable checkcolumn in TreePanel



sl5337
4 Sep 2014, 1:12 PM
I would like to disable the checkcolumn in a given node of a TreePanel based on data that I have at the time the node is created as well as data from events that might occur while the user is working with the application.

I can make the node look disabled by dynamically setting the 'cls' attribute when I create the node. However, I do not know how to get access to the checkcolumn to enable or disable it.

I have tried listening for the beforecellclick, beforecellmousedown, beforeitemclick events of the TreePanel but returning false from any of these had no effect. It seems I need something like a beforecheckchange event to listen for. I see that the checkcolumn has a beforecheckchange event, but again, I don't know how to get access to the checkcolumn after the node has been created.

I've tried using Ext.ComponentQuery to look for checkcolumn components:


Ext.ComponentQuery.query('myTreePanel checkcolumn')

but it returns an empty array.

Any help is greatly appreciated.

sl5337
5 Sep 2014, 4:43 AM
Solved it in the following manner:

Extended Ext.tree.Column and modifed cellTpl to evaluate a 'disabled' property of the record which I set dynamically when I create the record:


'<input type="button" {ariaCellCheckboxAttr}',
' class="{childCls} {checkboxCls}<tpl if="checked"> {checkboxCls}-checked</tpl>"
<tpl if="disabled"> disabled </tpl>/>',
'</tpl>',

Unfortunately I also had to override the entire initTemplateRendererData function of TreeColumn and add my 'disabled' field to the return statement in order for the template to recognize it:


return {
...
disabled:data.disabled,
...
};

Seems like I only would have had to add the 'disabled' field to my model and specify that model as the model for my store but after doing that the template still did not know that there was a disabled property of the record so I hardcoded it as above.

After all of that I was able to dynamically enable/disable the checkbox on the initial creation of the treepanel and from an event listener which set the 'disabled' property of the record based on external events.