如何在 ExtJS 4.1 树面板中找到第 n 个 child 个节点
How to find nth child nodes in ExtJS 4.1 tree panel
请检查以下内容fiddle。我有一个名为Grand Parent
的节点,这个节点有两个child:Child Node
& Child Two
.
当用户单击 Grand Parent 节点时,我想向下移动到层次结构中的最后一个节点并更新每个节点中的 属性 之一。
点击 Grand Parent
节点,我可以访问 Child Node
和 Child two
节点,但我找不到他们的 child。
向下查找层次结构中每个 child 节点的方法是什么。
您可以为此目的使用 'cascade'
方法。 (http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.container.AbstractContainer-method-cascade)
喜欢这个fiddlehttp://jsfiddle.net/j27rfzu6/1/
var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [{
text: "Grand Parent",
checked: false,
isSelected: false,
id: '1',
children: [{
text: 'Child Node',
checked: false,
IsSelected: false,
id: '1.1',
children: [{
text: "Grand Child One",
expanded: true,
checked: false,
isSelected: false,
id: '1.1.1',
}, {
text: "Grand Child Two",
expanded: true,
checked: false,
isSelected: false,
id: '1.1.2',
}, {
text: "Grand Child Three",
expanded: true,
checked: false,
isSelected: false,
id: '1.1.3',
}]
}, {
text: 'Child Two',
checked: false,
isSelected: false,
id: '1.2',
children: [{
text: "Grand Child Four",
expanded: true,
checked: false,
isSelected: false,
id: '1.2.1',
}]
}]
}]
}
});
Ext.create('Ext.tree.Panel', {
title: 'Example Tree',
width: 200,
height: 450,
store: store,
rootVisible: false,
multiSelect: true,
renderTo: Ext.getBody(),
listeners: {
itemclick: function (thisGrid, record, item, index, e, eOpts) {
record.cascade( function(){
alert(this.get('text'));
});
var v = 10;
alert('clicked');
}
}
});
请检查以下内容fiddle。我有一个名为Grand Parent
的节点,这个节点有两个child:Child Node
& Child Two
.
当用户单击 Grand Parent 节点时,我想向下移动到层次结构中的最后一个节点并更新每个节点中的 属性 之一。
点击 Grand Parent
节点,我可以访问 Child Node
和 Child two
节点,但我找不到他们的 child。
向下查找层次结构中每个 child 节点的方法是什么。
您可以为此目的使用 'cascade'
方法。 (http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.container.AbstractContainer-method-cascade)
喜欢这个fiddlehttp://jsfiddle.net/j27rfzu6/1/
var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [{
text: "Grand Parent",
checked: false,
isSelected: false,
id: '1',
children: [{
text: 'Child Node',
checked: false,
IsSelected: false,
id: '1.1',
children: [{
text: "Grand Child One",
expanded: true,
checked: false,
isSelected: false,
id: '1.1.1',
}, {
text: "Grand Child Two",
expanded: true,
checked: false,
isSelected: false,
id: '1.1.2',
}, {
text: "Grand Child Three",
expanded: true,
checked: false,
isSelected: false,
id: '1.1.3',
}]
}, {
text: 'Child Two',
checked: false,
isSelected: false,
id: '1.2',
children: [{
text: "Grand Child Four",
expanded: true,
checked: false,
isSelected: false,
id: '1.2.1',
}]
}]
}]
}
});
Ext.create('Ext.tree.Panel', {
title: 'Example Tree',
width: 200,
height: 450,
store: store,
rootVisible: false,
multiSelect: true,
renderTo: Ext.getBody(),
listeners: {
itemclick: function (thisGrid, record, item, index, e, eOpts) {
record.cascade( function(){
alert(this.get('text'));
});
var v = 10;
alert('clicked');
}
}
});