首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

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

2012-06-26 
Ztree树节点模糊搜索(兼容ie和firefox)通过获取输入框值,模糊查找树节点。var count0var lastNamefuncti

Ztree树节点模糊搜索(兼容ie和firefox)
通过获取输入框值,模糊查找树节点。
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;
}
}
}

热点排行
Bad Request.