获取Dojo树中选定节点的标签或名称

时间:2019-05-02 07:36:07

标签: dojo dijit.tree

我是dojo的新手。我有一个要求,我需要获取dojo树中选定节点的标签。

我如何实现这种情况?

注意:我在“树”节点上的父级和子级都有一个复选框。我只想获取所选节点的获取标签。

谢谢。

我尝试获取treeNode并获取checkbox属性,该属性在标签存在的地方具有innertText,但没有输出。

var systemModel = new ObjectStoreModel({                                 store:新的Observable(attributesStore),                                 查询:{id:“ root_” + sysId +'_'+ versionNum},                                 deferItemLoadingUntilExpand:true,                                 mayHaveChildren:函数(项目){                                     返回(item.level <6);                                 }                             });

                        // Create System version Tree
                        var systemTree = new Tree({
                            colspan: 5,
                            class: 'systemTreeWidget',
                            model: systemModel,
                            showRoot: false,
                            getLabel: function(item) {
                                return item.name;
                            },
                            getTooltip: function(item) {
                                if(item.parent == 'root') {
                                    return "";
                                } else {
                                    return item.name;
                                }                       
                            },                                  
                            getIconClass: function(item, opened) {
                                return item.iconType;

                            },
                            _createTreeNode: function (args) {
                                var tnode = new Tree._TreeNode(args);
                                tnode.labelNode.innerHTML = args.label;
                                console.log("tnode.labelNode.innerHTML:"+tnode.labelNode.innerHTML) 

                                    var cb = new CheckBox({             
                                        name: "availablePChk",                      
                                        value:args.item.id+":"+args.item.name+":"+args.item.parent+":"+ args.item.type                      
                                    });                             
                                    cb.placeAt(tnode.labelNode, "first");
                                    tnode.checkBox = cb;

                                    connect.connect(cb, "onChange", function () {
                                        debugger
                                        var treeNode = dijit.getEnclosingWidget(this.domNode.parentNode);                           
                                        console.log("treeNode:"+treeNode)   
                                        connect.publish("/checkbox/clicked", [{
                                            "checkbox": this,
                                            "item": treeNode.item
                                        }]);

                                        var id = tnode.domNode.id;
                                        var isNodeSelected = tnode.checkBox.get('checked');

// tab.query('#'+ id +'.dijitCheckBox')。forEach(function(node){                                             treeNode.getChildren()。forEach(function(node){ // dijit.getEnclosingWidget(node).set('checked',isNodeSelected);                                                 var child = dijit.getEnclosingWidget(node);                                                 child.set('checked',isNodeSelected);                                             });                                         });

                                return tnode;
                            }
                        }); 
                        systemTree.startup();

我想要选择其checbox的选定树节点的名称。

0 个答案:

没有答案