博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Dojo Tree设置默认选中项并且获得它
阅读量:5882 次
发布时间:2019-06-19

本文共 1579 字,大约阅读时间需要 5 分钟。

先上用来生成Tree的JSON数据

  [

    { "id": "Root", "name": "资源目录" },
    { "id": "PF", "name": "批发价格", "parent": "Root" },
    { "id": "PF93", "name": "93#", "parent": "PF" },
    { "id": "PF931", "name": "中石油","type":"WholeSale93CNPC","parent": "PF93" },
    { "id": "PF932", "name": "中石化","type":"WholeSale93SINO", "parent": "PF93" },
    { "id": "PF933", "name": "社会单位","type":"WholeSale93Other", "parent": "PF93" },
    { "id": "PF0", "name": "0#", "parent": "PF" },
    { "id": "PF01", "name": "中石油","type":"WholeSale0CNPC", "parent": "PF0" },
    { "id": "PF02", "name": "中石化","type":"WholeSale0SINO", "parent": "PF0" },
    { "id": "PF03", "name": "社会单位","type":"WholeSale0Other", "parent": "PF0" },
    { "id": "LS", "name": "零售价格", "parent": "Root" },
    { "id": "LS93", "name": "93#", "parent": "LS" },
    { "id": "LS931", "name": "中石油","type":"Retail93CNPC", "parent": "LS93" },
    { "id": "LS932", "name": "中石化","type":"Retail93SINO", "parent": "LS93" },
    { "id": "LS933", "name": "社会单位","type":"Retail93Other","parent": "LS93" },
    { "id": "LS0", "name": "0#", "parent": "LS" },
    { "id": "LS01", "name": "中石油", "type":"Retail0CNPC", "parent": "LS0" },
    { "id": "LS02", "name": "中石化", "type":"Retail0SINO", "parent": "LS0" },
    { "id": "LS03", "name": "社会单位", "type":"Retail0Other", "parent": "LS0" }
]

树生成之后,设置批发价格93#中石油为默认选中项。

leftTree.set('paths', [

['Root', 'PF', 'PF93', 'PF931']
]);
leftTree.focusNode(registry.byId("dijit__TreeNode_3"));
leftTree.set("selectedNodes", [registry.byId("dijit__TreeNode_3")]);
currentTreeItem = leftTree.get('selectedItems')[0];

效果图:

转载于:https://www.cnblogs.com/shuishuowobushihuiyuan/p/3772116.html

你可能感兴趣的文章
CSS魔法堂:Transition就这么好玩
查看>>
【OpenStack】network相关知识学习
查看>>
centos 7下独立的python 2.7环境安装
查看>>
[日常] 算法-单链表的创建
查看>>
前端工程化系列[01]-Bower包管理工具的使用
查看>>
使用 maven 自动将源码打包并发布
查看>>
Spark:求出分组内的TopN
查看>>
Python爬取豆瓣《复仇者联盟3》评论并生成乖萌的格鲁特
查看>>
关于跨DB增量(增、改)同步两张表的数据小技巧
查看>>
学员会诊之03:你那惨不忍睹的三层架构
查看>>
vue-04-组件
查看>>
Golang协程与通道整理
查看>>
解决win7远程桌面连接时发生身份验证错误的方法
查看>>
C/C++ 多线程机制
查看>>
js - object.assign 以及浅、深拷贝
查看>>
python mysql Connect Pool mysql连接池 (201
查看>>
Boost在vs2010下的配置
查看>>
一起谈.NET技术,ASP.NET伪静态的实现及伪静态的意义
查看>>
20款绝佳的HTML5应用程序示例
查看>>
string::c_str()、string::c_data()及string与char *的正确转换
查看>>