简体   繁体   English

如何使dijit树文件夹可选?

[英]how to make dijit tree folders selectable?

I have a tree in which i want the onOpen and onClose to be called only when the user clicks on the +/- icon and not if he clicks anywhere on the line that contains the folder. 我有一棵树,我希望仅当用户单击+/-图标时才调用onOpen和onClose,而如果他单击包含文件夹的行中的任意位置,则不希望它。 then I want the onClick event fired whenever the user clicks on the line where the folder is(except for on the expand/collapse icon). 那么我希望每当用户单击文件夹所在的行时都触发onClick事件(在展开/折叠图标上除外)。 I have tried looking at the node passed to the onopen by default and also have tried looking at the node sent by the onclick. 我尝试查看默认情况下传递给onopen的节点,也尝试查看onclick发送的节点。 It seems that onopen ovverides onclick internally. 似乎onopen ovverides内部onclick。 Please give me a direction to approach this issue. 请给我指导以解决此问题。

Thanks in Advance! 提前致谢!

Looks like there is a flag you can pass to the Tree to do this: 看起来有一个标志可以传递给Tree来执行此操作:

// openOnClick: Boolean
// If true, clicking a folder node's label will open it, rather than calling onClick()
openOnClick: false,

You would use it like this: 您可以这样使用它:

var myTree = new Tree({
    ..., //the other arguments you are already using
    openOnClick: true
});

In the future, I recommend checking the API docs or the source code for the widgets you are using. 以后,建议您检查API文档或您正在使用的小部件的源代码。 You will find that you will often stumble across useful features like this and that the Dojo source code is well organized and easy to read so its a good place to check whenever you have a doubt about how something works. 您会发现经常会发现诸如此类的有用功能,并且Dojo源代码组织良好且易于阅读,因此当您对某些事物的工作方式有疑问时,它是检查的好地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM