如何自动展开treeview第一级

childbaby 2006-01-17 05:20:29
d = new dTree('d');

d.config.closeSameLevel=false;
d.config.useCookies=false;
d.icon.root = "../images/tree/empty.gif";
d.add(0,-1,'','');
d.add(1,0,'sample','#');

document.write(d);
...全文
481 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
meizz 2006-01-19
  • 打赏
  • 举报
回复
向写这个树代码的作者咨询,这些个人写的树
childbaby 2006-01-19
  • 打赏
  • 举报
回复
顶,是不是我描述的不清楚?还是分太少
zxcvbnmluton 2006-01-19
  • 打赏
  • 举报
回复
<div class="dtree">
<p><a href="javascript: d.openAll();">open all</a> | <a href="javascript: d.closeAll();">close all</a></p>
<script type="text/javascript">
<!--
d = new dTree('d');
d.add(0,-1,'My example tree');
d.add(1,0,'Node 1','example01.html');
d.add(2,0,'Node 2','example01.html');
d.add(3,1,'Node 1.1','example01.html');
d.add(4,0,'Node 3','example01.html');
d.add(5,3,'Node 1.1.1','example01.html');
d.add(6,5,'Node 1.1.1.1','example01.html');
d.add(7,0,'Node 4','example01.html');
d.add(8,1,'Node 1.2','example01.html');
d.add(9,0,'My Pictures','example01.html','Pictures I\'ve taken over the years','','','img/imgfolder.gif');
d.add(10,9,'The trip to Iceland','example01.html','Pictures of Gullfoss and Geysir');
d.add(11,9,'Mom\'s birthday','example01.html');
d.add(12,0,'Recycle Bin','example01.html','','','img/trash.gif');
document.write(d);
//-->
</script>
</div>
childbaby 2006-01-19
  • 打赏
  • 举报
回复
// Checks if a node has any children and if it is the last sibling
dTree.prototype.setCS = function(node) {
var lastId;
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.id) node._hc = true;
if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;
}
if (lastId==node.id) node._ls = true;
};

// Returns the selected node
dTree.prototype.getSelected = function() {
var sn = this.getCookie('cs' + this.obj);
return (sn) ? sn : null;
};

// Highlights the selected node
dTree.prototype.s = function(id) {
if (!this.config.useSelection) return;
var cn = this.aNodes[id];
if (cn._hc && !this.config.folderLinks) return;
if (this.selectedNode != id) {
if (this.selectedNode || this.selectedNode==0) {
eOld = document.getElementById("s" + this.obj + this.selectedNode);
eOld.className = "node";
}
eNew = document.getElementById("s" + this.obj + id);
eNew.className = "nodeSel";
this.selectedNode = id;
if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
}
};

// Toggle Open or close
dTree.prototype.o = function(id) {
var cn = this.aNodes[id];
this.nodeStatus(!cn._io, id, cn._ls);
cn._io = !cn._io;
if (this.config.closeSameLevel) this.closeLevel(cn);
if (this.config.useCookies) this.updateCookie();
};

// Open or close all nodes
dTree.prototype.oAll = function(status) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {
this.nodeStatus(status, n, this.aNodes[n]._ls)
this.aNodes[n]._io = status;
}
}
if (this.config.useCookies) this.updateCookie();
};

// Opens the tree to a specific node
dTree.prototype.openTo = function(nId, bSelect, bFirst) {
if (!bFirst) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].id == nId) {
nId=n;
break;
}
}
}
var cn=this.aNodes[nId];
if (cn.pid==this.root.id || !cn._p) return;
cn._io = true;
cn._is = bSelect;
if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);
if (this.completed && bSelect) this.s(cn._ai);
else if (bSelect) this._sn=cn._ai;
this.openTo(cn._p._ai, false, true);
};
childbaby 2006-01-19
  • 打赏
  • 举报
回复
// Creates the tree structure
dTree.prototype.addNode = function(pNode) {
var str = '';
var n=0;
if (this.config.inOrder) n = pNode._ai;
for (n; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == pNode.id) {
var cn = this.aNodes[n];
cn._p = pNode;
cn._ai = n;
this.setCS(cn);
if (!cn.target && this.config.target) cn.target = this.config.target;
if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
if (!this.config.folderLinks && cn._hc) cn.url = null;
if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {
cn._is = true;
this.selectedNode = n;
this.selectedFound = true;
}
str += this.node(cn, n);
if (cn._ls) break;
}
}
return str;
};

// Creates the node icon, url and text
dTree.prototype.node = function(node, nodeId) {
var str = '<div class="dTreeNode">' + this.indent(node, nodeId);
if (this.config.useIcons) {
if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
if (this.root.id == node.pid) {
node.icon = this.icon.root;
node.iconOpen = this.icon.root;
}
if(node._hc)
{
str += '<img align="absmiddle" id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';
}
else
{
if(node.chec)
{
str += '<input type="checkbox" onclick="selChes(this)" name="ids" value="'+node.chec+'" gbkvalue="'+node.name+'"><img align="absmiddle" id="i' + this.obj + nodeId + '" style="width:0;height:0" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';
}
else
{
str += '<img align="absmiddle" id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';
}
}
}
if (node.url) {
str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';
if (node.title) str += ' title="' + node.title + '"';
if (node.target) str += ' target="' + node.target + '"';
if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';
if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';
str += '>';
}
else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';
str += node.name;
if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';
str += '</div>';
if (node._hc) {
str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';
str += this.addNode(node);
str += '</div>';
}
this.aIndent.pop();
return str;
};

// Adds the empty and line icons
dTree.prototype.indent = function(node, nodeId) {
var str = '';
if (this.root.id != node.pid) {
for (var n=0; n<this.aIndent.length; n++)
str += '<img align="absmiddle" src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />';
(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
if (node._hc) {
str += '<span onclick="javascript: ' + this.obj + '.o(' + nodeId + ');"><img align="absmiddle" id="j' + this.obj + nodeId + '" src="';
if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );
str += '" alt="" /></span>';
} else str += '<img align="absmiddle" src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />';
}
return str;
};
childbaby 2006-01-19
  • 打赏
  • 举报
回复
/*--------------------------------------------------|
| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
|---------------------------------------------------|
| Copyright (c) 2002-2003 Geir Landr? |
| |
| This script can be used freely as long as all |
| copyright messages are intact. |
| |
| Updated: 17.04.2003 |
|--------------------------------------------------*/

// Node object
function Node(id, pid, name, url, title, target, icon, chec , iconOpen, open) {
this.id = id;
this.pid = pid;
this.name = name;
this.url = url;
this.title = title;
this.target = target;
this.icon = icon;
this.chec = chec;
this.iconOpen = iconOpen;
this._io = open || false;
this._is = false;
this._ls = false;
this._hc = false;
this._ai = 0;
this._p;
};

// Tree object
function dTree(objName) {
this.config = {
target : null,
folderLinks : true,
useSelection : true,
useCookies : true,
useLines : true,
useIcons : true,
useStatusText : false,
closeSameLevel : false,
inOrder : false,
repeat : false//是否复选
}
this.icon = {
root : '../images/tree/base.gif',
folder : '../images/tree/folder.gif',
folderOpen : '../images/tree/folderopen.gif',
node : '../images/tree/page.gif',
empty : '../images/tree/empty.gif',
line : '../images/tree/line.gif',
join : '../images/tree/join.gif',
joinBottom : '../images/tree/joinbottom.gif',
plus : '../images/tree/plus.gif',
plusBottom : '../images/tree/plusbottom.gif',
minus : '../images/tree/minus.gif',
minusBottom : '../images/tree/minusbottom.gif',
nlPlus : '../images/tree/nolines_plus.gif',
nlMinus : '../images/tree/nolines_minus.gif'
};
this.obj = objName;
this.aNodes = [];
this.aIndent = [];
this.root = new Node(-1);
this.selectedNode = null;
this.selectedFound = false;
this.completed = false;

};

// Adds a new node to the node array
dTree.prototype.add = function(id, pid, name, url, title, target, icon, chec , iconOpen, open) {
this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, chec , iconOpen, open);
};

// Open/close all nodes
dTree.prototype.openAll = function() {
this.oAll(true);
};
dTree.prototype.closeAll = function() {
this.oAll(false);
};

// Outputs the tree to the page
dTree.prototype.toString = function() {
var str = '<div class="dtree">\n';
if (document.getElementById) {
if (this.config.useCookies) this.selectedNode = this.getSelected();
str += this.addNode(this.root);
} else str += 'Browser not supported.';
str += '</div>';
if (!this.selectedFound) this.selectedNode = null;
this.completed = true;
return str;
};
vf6.0,要考二级没系统的下哈 Microsoft Visual FoxPro 6.0 for Windows 的常见问题 这些是有关 Microsoft Visual FoxPro 最常见的问题。在您求助 Microsoft 产品支持服务之前,请先查阅这张列表。 若想打印这些附注,请从“文件”菜单中选择“打印”命令。此文档分为以下四部分: --------------------------------------------------------------------- 部分 1. 技术支持与市场 部分 2. Visual FoxPro 6.0 新增功能 部分 3. 从其他版本的 FoxPro 和 Visual FoxPro 中移植 部分 4. Visual FoxPro 常见问题 --------------------------------------------------------------------- 部分 1. 技术支持与市场 问题 1-1: 从何处可以获得产品的更新版本? 答案: 在 Visual FoxPro 的 Web 站点上即可获得产品的更新信息,其中包括有关 Service Pack 和更新的示例、向导及其他代码的信息,该站点的网址为: www.microsoft.com/vfoxpro 请定期查看该网站,以便下载产品的最新版本。 问题 1-2: 从何处可以得到有关 Visual FoxPro 的详细资料? 答案: 通过 Microsoft Visual FoxPro Web 站点是随时获得各种最新产品发布信息的最佳途径。在此站点上不仅有新的产品公告,而且还提供了产品的更新信息、技术文章、白皮书、专业开发人员设计的优秀示例、会议公告、以及与其他许多 FoxPro web 站点的各种链接。 问题 1-3: 如何获得技术支持,以及如何报告软件错误? 答案: Microsoft Visual FoxPro Web 站点已经链接到了多种联机支持选项,其中包括覆盖面广阔的有关所有产品 Microsoft Knowledge Base(Microsoft 知识库)。您还可以阅读一份有关常见问题的清单。除联机支持之外,还可以直接通过电话获得技术支持。“帮助”菜单中的选项可列出技术支持的电话号码。这些电话号码也可用于报告产品中的错误。 问题 1-4. 什么是 Knowledge Base?如何使用它? 答案: Knowledge Base 是内容广泛的论文集,覆盖了如何使用产品的各种特性、已知的软件错误及其解决方案或回避的方法、以及其他有助于使用各种 Microsoft 产品的有用信息。通过以下站点可访问整个 Knowledge Base: support.microsoft.com 问题 1-5: 是否会有 Visual FoxPro 6.0a? 答案: Microsoft 公司一向承诺为用户提供高质量的产品。如果确实需要,我们将提供 Visual FoxPro 6.0 的错误修订版。但是,修订版不会使用 6.0a 版的形式。Visual FoxPro 6.0 中任何错误的修正都将包含在 Visual Studio Service Pack 中。同时还会在 Visual FoxPro 的 www.microsoft.com/vfoxpro 或 Visual Studio 的www.microsoft.com/vstudio 的 Web 站点上发布修订公告。 问题 1-6: Microsoft 公司为应用程序的开发提供了一些优秀的解决方案。怎样才能知道应该向客户推荐和使用哪种产品? 答案: 在选择适用某项任务的产品时,需要考虑多方面的因素。Microsoft Visual FoxPro web 站点上有一份优秀的策略背景论文,它比较了 Visual FoxPro、Visual Basic、SQL Server 和 Access 等 Microsoft 产品之间的不同。 问题 1-7: 哪里可以找到 Visual FoxPro 的使用示例? 答案: Visual FoxPro 6.0 产品中带有丰富的示例,其中有一些是针对 6.0 版特有功能的新示例。与 Visual FoxPro 以前的版本不同,这些示例将与所有 Visual Studio 示例安装在一起。您必须运行 MSDN Library 的“自定义”安装来安装这些示例。在 Visual FoxPro 中可使用新的 HOME(2) 函数方便地找到已安装示例的位置。 除了产品中所自带的示例外,Microsoft Visual FoxPro web 站点还将经常提供新的示例。
第1章Range(单元格)对象8 技巧1单元格的引用方法8 1-1使用Range属性8 1-2使用Cells属性9 1-3使用快捷记号9 1-4使用Offset属性10 1-5使用Resize属性11 1-6使用Union方法12 1-7使用UsedRange属性12 1-8使用CurrentRegion属性13 技巧2选定单元格区域的方法13 2-1使用Select方法13 2-2使用Activate方法14 2-3使用Goto方法15 技巧3获得指定行、列中的最后一个非空单元格15 技巧4定位单元格18 技巧5查找单元格19 5-1使用Find方法19 5-2使用Like运算符23 技巧6替换单元格内字符串24 技巧7复制单元格区域25 技巧8仅复制数值到另一区域28 8-1使用选择性粘贴28 8-2直接赋值的方法29 技巧9单元格自动进入编辑状态30 技巧10禁用单元格拖放功能30 技巧11单元格格式操作31 11-1单元格字体格式设置31 11-2设置单元格内部格式33 11-3为单元格区域添加边框34 11-4灵活设置单元格的行高列宽36 技巧12单元格中的数据有效性37 12-1在单元格中建立数据有效性37 12-2判断单元格是否存在数据有效性39 12-3动态的数据有效性39 12-4自动展开数据有效性下拉列表41 技巧13单元格中的公式42 13-1在单元格中写入公式42 13-2检查单元格是否含有公式43 13-3判断单元格公式是否存在错误44 13-4取得单元格中公式的引用单元格45 13-5将单元格中的公式转换为数值46 技巧14单元格中的批注47 14-1判断单元格是否存在批注47 14-2为单元格添加批注48 14-3删除单元格中的批注49 技巧15合并单元格操作50 15-1判断单元格区域是否存在合并单元格50 15-2合并单元格时连接每个单元格的文本51 15-3合并内容相同的连续单元格52 15-4取消合并单元格时在每个单元格中保留内容54 技巧16高亮显示单元格区域55 技巧17双击被保护单元格时不显示提示消息框56 技巧18重新计算工作表指定区域58 技巧19录入数据后单元格自动保护58 技巧20工作表事件Target参数的使用方法60 20-1使用单元格的Address 属性60 20-2使用Column属性和Row属性61 20-3使用Intersect方法61 第2章Worksheet(工作表)对象63 技巧21引用工作表的方式63 21-1使用工作表的名称63 21-2使用工作表的索引号63 21-3使用工作表的代码名称64 21-4使用ActiveSheet属性引用活动工作表64 技巧22选择工作表的方法65 技巧23遍历工作表的方法66 23-1使用For...Next 语句66 23-2使用For Each...Next 语句68 技巧24在工作表中上下翻页69 技巧25工作表的添加与删除70 技巧26禁止删除指定工作表74 技巧27自动建立工作表目录76 技巧28工作表的深度隐藏78 技巧29防止更改工作表的名称80 技巧30工作表中一次插入多行81 技巧31删除工作表中的空行82 技巧32删除工作表的重复行84 技巧33定位删除特定内容所在的行86 技巧34判断是否选中整行87 技巧35限制工作表的滚动区域88 技巧36复制自动筛选后的数据区域89 技巧37使用高级筛选获得不重复记录91 技巧38工作表的保护与解除保护92 技巧39奇偶页打印95 第3章Wordbook(工作簿)对象97 技巧40工作簿的引用方法97 40-1使用工作簿的名称97 40-2使用工作簿的索引号97 40-3使用ThisWorkbook98 40-4使用ActiveWorkbook99 技巧41新建工作簿文件99 技巧42打开指定的工作簿101 技巧43判断指定工作簿是否打开104 43-1遍历Workbooks集合方法104 43-2错误处理方法104 技巧44禁用宏则关闭工作簿105 技巧45关闭工作簿不显示保存对话框109 45-1使用Close方法关闭工作簿109 45-2单击工作簿关闭按钮关闭工作簿111 技巧46禁用工作簿的关闭按钮111 技巧47保存工作簿的方法113 47-1使用Save方法113 47-2直接保存为另一文件名113 47-3保存工作簿副本113 技巧48保存指定工作表为工作簿文件114 技巧49打印预览时不触发事件116 技巧50设置工作簿文档属性信息118 技巧51不打开工作簿取得其他工作簿数据119 51-1使用公式119 51-2使用GetObject函数120 51-3隐藏Application对象121 51-4使用ExecuteExcel4Macro

87,922

社区成员

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

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