gpt4 book ai didi

extjs - 树的子节点/节点上的单击事件

转载 作者:行者123 更新时间:2023-12-04 11:40:26 24 4
gpt4 key购买 nike

我真的被 ExtJs 树对象弄糊涂了,我的代码有问题,但我不知道是什么。

考虑我有这个代码:

var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [
{ text: "detention", leaf: true },
{ text: "homework", expanded: true, children: [
{ text: "book report", leaf: true },
{ text: "alegrbra", leaf: true}
] },
{ text: "buy lottery tickets", leaf: true }
]
}
});

Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 200,
height: 150,
store: store,
rootVisible: false,
renderTo: Ext.getBody()
});

如何绑定(bind) 点击我的树的 child /叶子的事件?

最佳答案

像这样?

var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [
{ text: "detention", leaf: true },
{ text: "homework", expanded: true, children: [
{ text: "book report", leaf: true },
{ text: "alegrbra", leaf: true}
] },
{ text: "buy lottery tickets", leaf: true }
]
}
});

Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 200,
height: 150,
store: store,
rootVisible: false,
renderTo: Ext.getBody(),
listeners: {
itemclick: function(s,r) {
alert(r.data.text);
}
}
});

看到这个 JSFiddle

关于extjs - 树的子节点/节点上的单击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14722335/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com