MzTreeView中产生树节点的方法是tree.nodes[pid_id] = "text:nodetext...."现在的问题是目录树产生以后,我想在双击时获取操作节点对应的主键,也就是上述方法传入的id值,然后针对该节点对应的数据路记录进行操作.我先前用的方法是在产生HTML的方法中做如下修改:
MzTreeView.prototype.nodeToHTML = function(node, AtEnd){
  
  .....
 
    HTML += "<IMG "+
    "align='absMiddle' "+
    "id='"+ this.name +"_icon_"+ id +"' "+
    "src='"+ this.icons[node.icon].src +"'><A "+
    "class='MzTreeview' hideFocus "+
    "id='"+ this.name +"_link_"+ id +"' "+
    "href='"+ url +"' "+
    "target='"+ target +"' "+
    "title='"+ node.hint +"' "+
    "onfocus=\""+ this.name +".focusLink('"+ id +"')\" "+
    "onclick=\"return "+ this.name +".nodeClick('"+ id +"')\""+ 
    "ondblclick= theDlClick('"+id+"')>"+
    node.text +
  "</A></NOBR></DIV>";  
   
   .....
}
function theDlClick(id){
// window.parent.detail.doClick(id);
window.alert(id+" is double clicked!");
};-----------------------
其中 "ondblclick= theDlClick('"+id+"')>"和function theDlClick(id){..}是我修改的.只是这里面传递的id其实不是对应记录的主键id.
请高手指教..

解决方案 »

  1.   

    楼上的你好,下面是配套例子的源码:--------------------------<%@ Language=VBScript codepage=936  %>
    <%  Option Explicit %>
    <%
      Dim Conn, rs
      Set Conn  = Server.CreateObject("ADODB.Connection")
      Set rs    = Server.CreateObject("ADODB.Recordset")  Conn.Open  "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="& Server.MapPath("./") &"\tree.mdb;"
      rs.open "Select ID, parentId, text, hint, icon, data, url, target, method From treeview order by ID", Conn
    %>
    <html>
      <head>
        <title>梅花雪中文网 - 网页脚本控件集 MzTreeView10</title>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
        <meta name="author" content="黄方荣(meizz·梅花雪)://www.meizz.com">
        <script language="JavaScript" src="MzTreeView10.js"></script>
        <link href="http://www.meizz.com/Scripts/Global.css" type="text/css" rel="stylesheet">
        <style>
        A.MzTreeview
        {
          font-size: 9pt;
          padding-left: 3px;
        }
        </style>
      </head>  <body class=frame>
        <SCRIPT LANGUAGE="JavaScript">
        <!--
        window.tree = new MzTreeView("tree");    tree.icons["property"] = "property.gif";
        tree.icons["css"] = "collection.gif";
        tree.icons["book"]  = "book.gif";
        tree.iconsExpand["book"] = "bookopen.gif"; //展开时对应的图片
        tree.setIconPath(""); //可用相对路径
    <%
      Dim node
      Dim reg : set reg = new RegExp : reg.global=True : reg.pattern=";"
      Dim id, parentId, text, hint, icon, data, url, target, method
      do while not rs.eof
        '若是树的条目比较多的时候(比如大于1000)而又相对稳定的时候将这些数据生成静态网页来访问
        node = VBCrLf &"    tree.nodes["""& rs("parentId") &"_"& rs("id") &"""] = """
        node = node &"text:"& reg.replace(rs("text"), chr(15)) &";"
        if rs("hint")<>"" then node = node &"hint:"& reg.replace(rs("hint"), chr(15)) &";"
    <!--    if rs("icon")<>"" then node = node &"icon:"& rs("icon") &";" -->
        if rs("data")<>"" then node = node &"data:"& reg.replace(rs("data"), chr(15)) &";"
        if rs("url")<>""  then node = node &"url:"&  reg.replace(rs("url"), chr(15)) &";"
        if rs("target")<>"" then node = node &"target:"& rs("target") &";"
        if rs("method")<>"" then node = node &"method:"& reg.replace(rs("method"), chr(15)) &";"
        response.write node &"""" '生成节点信息
        rs.movenext
      loop
    %>
        tree.setURL("Catalog.asp");
        tree.setTarget("MzMain");
        document.write(tree.toString());    //亦可用 obj.innerHTML = tree.toString();
        //-->
        </SCRIPT>
      </body>
    </html>
    <%
      rs.close : set rs = nothing : Conn.close : set Conn = nothing
    %>----------------------------我不懂ASP,上面的我大致看的明白的就是,从数据库中retrive,然后逐条生成nodes.若说获取ID好像仅在遍历resultset的时候有一次.我要做的是,在mztreeview.js中,通过js获取id然后传递出去.可能是我不懂asp的缘故.楼上的可否进一步赐教? 谢谢!
      

  2.   

    问题进一步阐述:其实要用一句话来概括我的问题就是:MzTreeView 利用数据库中的pid、id生成目录树之后,我想在js中获取原id,也就是目录树条目对应的原数据库的主键。请高手指教...