我有树梢。我想点击唯一的子元素来发起一个事件。
在我的itemclick
事件中,当我点击时,它一直在触发。我只想在点击最后一个孩子时才开火。
例如:它应该激活“管理应用程序子”而不是“管理应用程序”
var root = {
expanded: true,
children: [{
text: "Configure Application",
expanded: true,
children: [{
text: "Manage Application",
children: [{
text: "Manage Application Child",
leaf: true
}]
}, {
text: "Scenario",
leaf: true
}]
}, {
text: "User Configuration",
expanded: true,
children: []
}, {
text: "Test Configuration",
//leaf: true,
expanded: true,
children: [{
text: "Manage User",
leaf: true
}, {
text: "User rights",
leaf: true
}]
}]
};
{
xtype: 'treepanel',
useArrows: true,
autoScroll: false,
animate: true,
enableDD: false,
title: 'Configuration',
width: 200,
height: 400,
rootVisible: false,
store: Ext.create('Ext.data.TreeStore', {
root: root
}),
listeners: {
itemclick: function (s, r) {
alert(r.data.text);
}
}
}
答案 0 :(得分:3)
如果我理解正确,你只需检查节点是否是" leaf":
itemclick: function (s, r) {
if (r.data.leaf){ //or r.data.children == null
alert(r.data.text);
}
}
答案 1 :(得分:0)
我创建FIDDLE我认为它会帮助你想要的东西