今天介绍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的更多相关文章

  1. 使用dojo的tree

    dojo的Tree非常是灵活,可是官方站点上的样例却非常少,并且也比較分散,兴许将持续完好本样例. 总的来说,要使用tree,要接触到三个类:"dojo/store/JsonRest&quo ...

  2. EasyUI 创建Tree

    tree可以被从标记创建.easyui tree应该定义在ul元素中.无序列表ul元素提供了基本tree结构.每一个li元素被产生一个tree节点,子ul元素产生父tree节点.例子:     < ...

  3. Extjs中创建Tree菜单【一】

    此篇treepanel的描写是很简单,没有太大的难度,在学习时,可以先熟悉tree的一些配置信息.属性.方法和事件. 然后先写一个简单的例子,慢慢了解从中如何实现的,然后在慢慢的深入了解,实现一些复杂 ...

  4. Creating Classes 创建类

    The dojo/_base/declare module is the foundation of class creation within the Dojo Toolkit. declare a ...

  5. Ternary Search Tree Java实现

    /** * @author Edwin Chen * */ //定义节点 class Node { //存储字符串 char storeChar; //是否完成单词 boolean isComplet ...

  6. XHR 框架与 Dojo( xhrGet,xhrPut,xhrDelete)

    总结 本文介绍了 Dojo 中三种浏览器与服务器交互的方式,这三种方式各有优缺点,但是在使用方式却出奇的一致: xhr 框架的函数,dojo.io.iframe.dojo.io.script 对象的函 ...

  7. EasyUI Editable Tree

    效果如图: Create Tree <ul id="tt"></ul> $('#tt').etree({ url: 'tree_data.json', cr ...

  8. 依赖layui form模块 复选框tree插件(拓展可根据属性单选还是多选,数据反选)

    近些天接的项目用的是layui.以前没用过,踩了很多坑,坑就不多说了,直接说layui的tree.因为自带的tree不满足需求,所以在论坛.博客上找了很久终于找到了可以复选的的插件,原文地址:http ...

  9. 使用 Dojo 掌握面向对象开发

    原文出处:Joe Lennon 从头开始学习 Dojo,第 2 部分 使用 Dojo 掌握面向对象开发 什么是面向对象开发? 面向对象编程(Object-Oriented Programming,OO ...

随机推荐

  1. 第一个Leap Motion测试页面 (webgl/three/leapjs/leap)

    div#canvas-frame{ border: none; cursor: pointer; width: 100%; height: 800px; background-color: #EEEE ...

  2. ShellExecute 使用方法

    ShellExecute的功能是运行一个外部程序(或者是打开一个已注册的文件.打开一个目录.打印一个文件等等),并对外部程序有一定的控制. 有几个API函数都可以实现这些功能,但是在大多数情况下She ...

  3. mvc图片上传到服务器

    链接:http://www.lanhusoft.com/Article/406.html

  4. 实时监听输入框值变化:oninput & onpropertychange

    结合 HTML5 标准事件 oninput 和 IE 专属事件 onpropertychange 事件来监听输入框值变化. oninput 是 HTML5 的标准事件,对于检测 textarea, i ...

  5. AIDL小结

    AIDL : Android Interface Define Language(接口定义语言) Service中跨进程间通信利器.... 一般都会有Client端和Server端(Server端提供 ...

  6. ZeroC Ice 暂记

    摘自: http://weibo.com/p/1001603869896789339575 原文地址: http://www.oschina.net/question/865233_242146 吴治 ...

  7. canvas知识点

    看到网上某些特别好看的效果,就突然想看看这个canvas; canvas是html5中的一个标签.所以兼容的是Internet Explorer 9.Firefox.Opera.Chrome 和 Sa ...

  8. Hex string convert to Binary String and Vise-Versa(16进制和2进制字符串的相互转换)

    这个转换在我们日常的编码中还是很有机会遇到的,这里贴出来和大家分享探讨. void pu_hex_to_binary(std::string strHex, std::string &strB ...

  9. Ajax的封装03

    一.Ajax   1.原理:基于http协议的     内置对象:XMLHttpRequest 发起请求 那会相应     步骤: var xhr=new XMLHttpRequest(); // 请 ...

  10. 使用Gson解析json

    前边的博客说过将json解析成java的方法,使用的是 这几个jar包,但是在解析时层遇到一个问题,就是在将时间字符串转换为java的Timestamp对象时会抛出异常,这个问题一直放在哪里没有去解决 ...