六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 215|回复: 0

Ztree树节点模糊搜索(兼容ie和firefox)

[复制链接]

升级  20%

2

主题

2

主题

2

主题

童生

Rank: 1

积分
10
 楼主| 发表于 2013-1-29 08:44:51 | 显示全部楼层 |阅读模式
通过获取输入框值,模糊查找树节点。
var count=0;
var lastName;
function searchTree(){
if(count==0){
lastName=document.getElementById("id").value;
}
if(lastName!=document.getElementById("id").value){
count=0;
lastName=document.getElementById("id").value;
}
var treeObj = $.fn.zTree.getZTreeObj("tree");
//通过名称模糊搜索,也可通过Id查找
var nodes =   treeObj.transformToArray(treeObj.getNodesByParamFuzzy("name", lastName, null));
               for(i = count; i < nodes.length; i++) {
count++;
if(count>=nodes.length){
count=0;
}
if(nodes[i].name.indexOf(lastName)!=-1){
treeObj.selectNode(nodes[i]);
if(nodes[i].icon=="xx.png"){
parent.mainFrame.location.href = "xx.jsp;
}else if(nodes[i].icon=="xx.png"){
parent.mainFrame.location.href = "xx.jsp";
}else if(nodes[i].icon=="xx.png"){
parent.mainFrame.location.href = "xx.jsp";
}
//实现自动打开
//treeObj.expandNode(nodes[i], false,false , false);
return;
}
}
}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表