日期:2014-05-16 浏览次数:20685 次
<%@ page contentType="text/html; charset=UTF-8"%> <%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html"%> <%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean"%> <%@ taglib uri="/WEB-INF/tld/biosam.tld" prefix="biosam"%> <%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic"%> <link rel="stylesheet" type="text/css" href="css/jquery.treeview.css"> <script language="javascript" type="text/javascript" src="js/jquery.numeric.js"></script> <script type="text/javascript" language="javascript" src="js/jquery.treeview.js"></script> <script type="text/javascript"> //JQuery树的展现 $(document).ready(function(){ $("#black").treeview({}); }); //通过ajax调用到后台得到树的节点 function getTreeNode(taxonId) { var xmlHttp; var getTreeNodeUrl = 'treeSource.do?taxonId='+taxonId; var ulId ='ul' + taxonId.substring(2); try { // Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch (e){ // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e) { return false; } } } xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4 && xmlHttp.responseXML) { //通过ajax得到数据变成xml标签 var searchResult = xmlHttp.responseXML; var treeList = searchResult.getElementsByTagName('node'); //得到想要的数据并拼成显示的字符串 if(treeList.length != 0) { for(var i=0 ; i<treeList.length ; i++) { var treeStr = ''; var tree = treeList.item(i); var eltaxonId = tree.getElementsByTagName('taxonID'); var taxonId = eltaxonId.item(0).firstChild.nodeValue.trim(); var eltaxonText = tree.getElementsByTagName('taxonText'); var taxonText = eltaxonText.item(0).firstChild.nodeValue.trim(); var elchilds = tree.getElementsByTagName('taxonSubCount'); var childs = elchilds.item(0).firstChild.nodeValue.trim(); var elsearchStr = tree.getElementsByTagName('taxonSearchStr'); var searchStr = elsearchStr.item(0).firstChild.nodeValue.trim(); treeStr = treeStr + "<li class='closed' "; treeStr = treeStr + "id='li" + taxonId + "' value='0' "; if(childs > 0) { treeStr = treeStr + "onclick='checkTreeNode(this)' >"; } else { treeStr = treeStr + ">"; } treeStr = treeStr + "<span onclick='changeColor(this)' id='span"; treeStr = treeStr + taxonId + "' value='0'>"; treeStr = treeStr + "<a style='text-decoration:none' onclick=\""; treeStr = treeStr + "doSel(this,'" + searchStr + "')\" "; treeStr = treeStr + "id='a" + taxonId + "' >"; treeStr = treeStr + taxonText; if(childs > 0) { treeStr = treeStr + " [" + childs + " Records]"; treeStr = treeStr + "</a>"; treeStr = treeStr + "</span>"; treeStr = treeStr +"<ul id='ul" + taxonId + "'></ul>"; } else { treeStr = treeStr + "</a>"; treeStr = treeStr + "</span>"; } treeStr = treeStr + "</li>"; var branches = $(treeStr).appendTo("#"+ulId); //刷新树 $("#black").treeview({ add: branches }); } } } } xmlHttp.open("POST",getTreeNodeUrl,true); xmlHttp.send(null); } //树节点作为检索条件,传入字符串 function doS