xtree扩展checkbox的父节点选中,子节点也选中!!~

danns888 2010-10-14 03:00:19
现在我的XTREE有checkbox,也可以正常显示树,就差checkbox的父节点选中,子节点也选中,还有如子节点全部取消,父节点也取消的问题,想试着自己封装,无奈JS是在太烂了,请各位帮忙看看啊,一下是我的XTREE.JS:
...全文
289 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
wula0010 2010-10-14
  • 打赏
  • 举报
回复
好好研究下js吧,还是自己慢慢改,这个对自己的能力有提高的,别图一时方便,.............
danns888 2010-10-14
  • 打赏
  • 举报
回复
都一样的啊,都是通过这个生成的啊
  • 打赏
  • 举报
回复
明白了。这是父节点?
那子节点呢?
danns888 2010-10-14
  • 打赏
  • 举报
回复
就红色部分啊,其他不用看的啊,然后写个Onclick事件就好了啊
  • 打赏
  • 举报
回复

晕了。如何看下去。不如找个类似的东西,你自己去模仿。
danns888 2010-10-14
  • 打赏
  • 举报
回复
WebFXTreeItem.prototype.toString = function (nItem, nItemCount) {
var foo = this.parentNode;
var indent = '';
if (nItem + 1 == nItemCount) { this.parentNode._last = true; }
var i = 0;
while (foo.parentNode) {
foo = foo.parentNode;
indent = "<img id=\"" + this.id + "-indent-" + i + "\" src=\"" + ((foo._last)?webFXTreeConfig.blankIcon:webFXTreeConfig.iIcon) + "\">" + indent;
i++;
}
this._level = i;
if (this.childNodes.length) { this.folder = 1; }
else { this.open = false; }
if ((this.folder) || (webFXTreeHandler.behavior != 'classic')) {
if (!this.icon) { this.icon = webFXTreeConfig.folderIcon; }
if (!this.openIcon) { this.openIcon = webFXTreeConfig.openFolderIcon; }
}
else if (!this.icon) { this.icon = webFXTreeConfig.fileIcon; }
var label = this.text.replace(/</g, '<').replace(/>/g, '>');
var str = "<div id=\"" + this.id + "\" ondblclick=\"webFXTreeHandler.toggle(this);\" class=\"webfx-tree-item\" onkeydown=\"return webFXTreeHandler.keydown(this, event)\">" +
indent +
"<img id=\"" + this.id + "-plus\" src=\"" + ((this.folder)?((this.open)?((this.parentNode._last)?webFXTreeConfig.lMinusIcon:webFXTreeConfig.tMinusIcon):((this.parentNode._last)?webFXTreeConfig.lPlusIcon:webFXTreeConfig.tPlusIcon)):((this.parentNode._last)?webFXTreeConfig.lIcon:webFXTreeConfig.tIcon)) + "\" onclick=\"webFXTreeHandler.focusI(this);webFXTreeHandler.blurI(this);"+this.action+"\">" +

"<input type='checkbox' name='checkGroupId"+this.kind+"' class='webfx-tree-checkbox' id='"+this.kind+this.targetId+"' value='"+this.targetId+"' />"+

"<img id=\"" + this.id + "-icon\" class=\"webfx-tree-icon\" src=\"" + ((webFXTreeHandler.behavior == 'classic' && this.open)?this.openIcon:this.icon) + "\" onclick=\"webFXTreeHandler.select(this);\">" +
"<a href=\"" + this.action + "\" id=\"" + this.id + "-anchor\" onfocus=\"webFXTreeHandler.focus(this);\" onblur=\"webFXTreeHandler.blur(this);\"" +
(this.target ? " target=\"" + this.target + "\"" : "") +
">" + label + "</a></div>" +
"<div id=\"" + this.id + "-cont\" class=\"webfx-tree-container\" style=\"display: " + ((this.open)?'block':'none') + ";\">";
var sb = [];
for (var i = 0; i < this.childNodes.length; i++) {
sb[i] = this.childNodes[i].toString(i,this.childNodes.length);
}
this.plusIcon = ((this.parentNode._last)?webFXTreeConfig.lPlusIcon:webFXTreeConfig.tPlusIcon);
this.minusIcon = ((this.parentNode._last)?webFXTreeConfig.lMinusIcon:webFXTreeConfig.tMinusIcon);
return str + sb.join("") + "</div>";
}

这个是TOSTRING方法,其中的CHECKBOX就是我要的,但是里面没有Oncilck事件
  • 打赏
  • 举报
回复
不太清楚。我只是偶尔上来转转,没上传过。
danns888 2010-10-14
  • 打赏
  • 举报
回复
LS的,是想用JS,扩展XTREE.JS,让他有我说的功能,文件太大,怎么上传啊
  • 打赏
  • 举报
回复
你是用纯JS 还是用jquery?
danns888 2010-10-14
  • 打赏
  • 举报
回复
晕,文件太大了,怎么上传??
yjflinchong 2010-10-14
  • 打赏
  • 举报
回复
用class id进行标记。 然后通过 你点击的父节点 获取参数,然后用jquery 把这个参数相关的子节点递归选择就行了。 代码会有点复杂。。
  • 打赏
  • 举报
回复
xtree.js.在哪?

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧