ExtJS 4 treepanel with checkbox issue
We are using treepanel with check box in our application.It seems like:
var treepanel = {
开发者_开发问答 id : 'tree', xtype : 'treepanel', store : layerStore, rootVisible : false, listeners : { checkchange : function(node,check){ if(node.get('id') == 'teacher'){ alert('you have selected teacher node'); }else if(node.get('id') == 'student'){ alert('you have selected student node'); } } } };
LayerStore code:
var layerStore = Ext.create('Ext.data.TreeStore',{
root : {
children : [
{
text : 'teacher layer',
id : 'teacher',
checked : false
},{
text : 'Student layer',
id : 'student',
checked : false
}]
}
});
Now,i am getting the alert message when we check on the particular checkbox.My problem is that if we uncheck the checkbox then it has to display the alert like you has unselected a particular layer.Please help me.
I quess You have to change your 'checkchange' handler to this:
checkchange : function(node,check){
var s = (!check && 'un' || '' ) + 'selected';
if(node.get('id') == 'teacher'){
alert('you have '+s+' teacher node');
}else if(node.get('id') == 'student'){ alert('you have '+s+' student node'); }
}
精彩评论