惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
D
Docker
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
宝玉的分享
宝玉的分享
腾讯CDC
Google Online Security Blog
Google Online Security Blog
Recorded Future
Recorded Future
T
The Exploit Database - CXSecurity.com
T
The Blog of Author Tim Ferriss
V
V2EX
S
Securelist
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
Y
Y Combinator Blog
P
Proofpoint News Feed
T
Tor Project blog
AWS News Blog
AWS News Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
T
Threat Research - Cisco Blogs
B
Blog
Attack and Defense Labs
Attack and Defense Labs
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
N
News and Events Feed by Topic
博客园 - 司徒正美
H
Help Net Security
C
Cisco Blogs
C
Check Point Blog
S
Secure Thoughts

博客园 - 灰色

OSGi中使用Servlet遇到Permission denied的问题 ubuntu上安装netbeans提示找不到jdk的解决办法 Ubuntu的eclipse+CDT开发遇到的问题 - 灰色 - 博客园 备忘:昨天被人问到的3个Linux命令,我只会一个,惭愧啊 vmware中Ubuntu同宿主机Windows之间的共享问题 Oracle创建数据库时提示out of memory错误解决办法 vmware中鼠标乱跑问题的解决 TB级数据检索引擎开发笔记(一) Windows Service中调用Winform程序之log4net问题. 常用SQL语句 要到新公司了 error LNK2001: unresolved external symbol _main解决办法(zz) Ubuntu下使用IronPython不支持os标准库的解决方法 我们公司正在实行的Scrum,效果还不错 如何将数据库恢复到不同名称的新库下 一分钟搞定清晰的网站图标(ico) SQL SERVER 孤立用户问题 - 灰色 利用DevExpress控件包中的GridControl做Master-Detail样式时,Detail表无法定位行的解决办法 Winform中Licenses.licx 总是签出导致影响多人开发的解决方法
改进的dtree,支持无刷新添加和删除节点
灰色 · 2008-12-25 · via 博客园 - 灰色

最近重构原有系统,需要将treeview改写成无刷新的形式,曾尝试对TreeView控件进行操作,但是太麻烦,无奈放弃.同事向我推荐了dtree,看了还不错,不过并不支持动态添加和删除节点,好在它的代码比较简单,直接修改了它的代码.点这里可以下载.压缩包里有全部的代码.主要的思路也是来自网上的一篇文章,用了一个备用数组存放之前的数据. 

但是在使用的过程中我也发现dtree的一个不便之处,就是它的ID必须是从0开始的索引,因为这个索引实际上是它存储节点数据的数组索引,无奈我对其节点对象进行了扩展,令其可以支持自己的节点ID

 1function Node(id, pid, name, url,cid,cpid, title, target, icon, iconOpen, open) {
 2    this.id = id;
 3    this.pid = pid;
 4    this.name = name;
 5    this.url = url;
 6    this.title = title;
 7    this.target = target;
 8    this.icon = icon;
 9    this.iconOpen = iconOpen;
10    this._io = open || false;
11    this._is = false;
12    this._ls = false;
13    this._hc = false;
14    this._ai = 0;
15    this._p;    
16    this.cid=cid;  //自定义的ID
17    this.cpid=cpid; //自定义的父ID
18}
;

另外,由于dtree的每个节点都已经定义了onclick事件(进行节点的展开和折叠),所以并不支持自己的事件(也可能是我没找到),所以我自己重新定义了一个. 

dTree.prototype.delegate=function(cid,cpid){}

 其中的cid和cpid是自定义的ID和父ID.然后在具体调用的页面像下面这样写就可以了.

a.delegate=function(accountID,accountPID)
{    
      //你的代码
}

至于添加和删除节点就不是很难了,大家自己看代码就可以了:)