dojo创建tree
今天介绍dojo目录树的效果,效果如下图:
HTML代码如下:
<body class="claro">
<div id="rootlessTree" data-dojo-type="dijit/Tree"></div>
</body>
Js代码如下:
require([
"dojo/dom",
"dojo/json",
"dojo/store/Memory",
"dijit/tree/ObjectStoreModel",
"dijit/Tree",
"dojo/domReady!"
], function(dom, json, Memory, ObjectStoreModel, Tree){
var ss='[{ "id":0, "name": "test", "aa": "ss"},{"id":1,"name":"a","Fartherid":0},{"id":8,"name":"b","Fartherid":0},{"id":11,"name":"c","Fartherid":0},
{"id":237,"name":"d","Fartherid":0},{"id":238,"name":"e","Fartherid":0},{"id":82,"name":"f","Fartherid":0},{"id":233,"name":"g","Fartherid":0},
{"id":246,"name":"h","Fartherid":0},{"id":9,"name":"i","Fartherid":8},{"id":10,"name":"j","Fartherid":8},{"id":12,"name":"k","Fartherid":11},
{"id":13,"name":"l","Fartherid":11},{"id":18,"name":"1","Fartherid":11},{"id":19,"name":"12","Fartherid":11},{"id":235,"name":"m","Fartherid":233},
{"id":239,"name":"n","Fartherid":238},{"id":245,"name":"o","Fartherid":238}]';
var dt = JSON.parse(ss);
continentStore = new Memory({
data: dt
});
continentStore.getChildren = function(object){
return this.query({Fartherid: this.getIdentity(object)});//Fartherid为绑定的父节点id
};
continentModel = new ObjectStoreModel({
store: continentStore,
query: {id:0}, //将该目录树绑定道节点为0的id上
mayHaveChildren: function(item){ //如果子节点没有内容,图标就显示成文档
console.log(item);
if(item.id===0) return true;
for(var i=0;i<dt.length;i++){
if(item.id===dt[i].Fartherid) return true;
}
return false;
}
});
var governmentTree = new Tree({
model: continentModel,
onOpenClick: true,
showRoot:true, //是否显示跟节点
onLoad: function(){ //加载完毕
console.log("plantTree");
},
onClick: function(item){ //单击事件
console.log(item);
},
persist: false
}, "rootlessTree");
governmentTree.startup();
});
dojo创建tree的更多相关文章
- 使用dojo的tree
dojo的Tree非常是灵活,可是官方站点上的样例却非常少,并且也比較分散,兴许将持续完好本样例. 总的来说,要使用tree,要接触到三个类:"dojo/store/JsonRest&quo ...
- EasyUI 创建Tree
tree可以被从标记创建.easyui tree应该定义在ul元素中.无序列表ul元素提供了基本tree结构.每一个li元素被产生一个tree节点,子ul元素产生父tree节点.例子: < ...
- Extjs中创建Tree菜单【一】
此篇treepanel的描写是很简单,没有太大的难度,在学习时,可以先熟悉tree的一些配置信息.属性.方法和事件. 然后先写一个简单的例子,慢慢了解从中如何实现的,然后在慢慢的深入了解,实现一些复杂 ...
- Creating Classes 创建类
The dojo/_base/declare module is the foundation of class creation within the Dojo Toolkit. declare a ...
- Ternary Search Tree Java实现
/** * @author Edwin Chen * */ //定义节点 class Node { //存储字符串 char storeChar; //是否完成单词 boolean isComplet ...
- XHR 框架与 Dojo( xhrGet,xhrPut,xhrDelete)
总结 本文介绍了 Dojo 中三种浏览器与服务器交互的方式,这三种方式各有优缺点,但是在使用方式却出奇的一致: xhr 框架的函数,dojo.io.iframe.dojo.io.script 对象的函 ...
- EasyUI Editable Tree
效果如图: Create Tree <ul id="tt"></ul> $('#tt').etree({ url: 'tree_data.json', cr ...
- 依赖layui form模块 复选框tree插件(拓展可根据属性单选还是多选,数据反选)
近些天接的项目用的是layui.以前没用过,踩了很多坑,坑就不多说了,直接说layui的tree.因为自带的tree不满足需求,所以在论坛.博客上找了很久终于找到了可以复选的的插件,原文地址:http ...
- 使用 Dojo 掌握面向对象开发
原文出处:Joe Lennon 从头开始学习 Dojo,第 2 部分 使用 Dojo 掌握面向对象开发 什么是面向对象开发? 面向对象编程(Object-Oriented Programming,OO ...
随机推荐
- 修改BIND9实现TCP DNS
近日适逢某平方节日,Google国外网站陆续出现被墙的状况,想必大家都是知道的. 其实本人一直在使用SSH的Socket代理功能爬梯子,效果还是不错的,加上学校有原生IPv6支持,就算不走代理一般也能 ...
- MS AX 技术相关网站收藏
Microsoft Dynamics AX Developer Centerhttps://msdn.microsoft.com/en-us/dynamics/ax/default.aspx From ...
- 高级php面试题(转)
一.mysql相关知识 1. mysql优化方式 MYSQL 优化常用方法 mysql 性能优化方案 2.如何分库分表 ...
- PIC32MZ tutorial -- External Interrupt
In my older blog "PIC32MZ tutorial -- Key Debounce", I shows how to acheive key debounce w ...
- js语言精粹读书笔记一
一.语法 1.
- javaWeb学习-----session
一.Session简单介绍 在WEB开发中,服务器可以为每个用户浏览器创建一个会话对象(session对象),注意:一个浏览器独占一个session对象(默认情况下).因此,在需要保存用户数据时,服务 ...
- ActiveMQ安装
安装环境: 逛网下载最新安装包,ubuntu下解压sudo tar -zxvf xx.tar.启动activeMQ. 报错如下: 原因是没有找到java命令位置,编辑启动配置文件: 再次启动,完成后进 ...
- ubuntu 'Unable to correct problems, you have held broken packages' 错误
在用apt 安装软件时,有时会用国内的源以加快下载速度. 但是在使用ubuntu 14.04的过程中,这一过程可能会导致错误“Unable to correct problems, you have ...
- mysql自动添加最后修改时间
字段不为空 NOT NULL 类型 :timestamp 默认值 :CURRENT_TIMESTAMP
- IDEA springMVC - hello world
记录所学,防忘记... ide用IDEA,用maven管理依赖包 1.建立一个maven-webapp项目:File->New->Project 2.pom.xml <project ...