ExtJS 4 treepanel with checkbox issue

时间秒杀一切 提交于 2020-01-06 08:24:08

问题


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.


回答1:


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'); }
}


来源:https://stackoverflow.com/questions/6694698/extjs-4-treepanel-with-checkbox-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!