怎样用javascript在treeview里边加checkbox啊?

解决方案 »

  1.   

    需要动态的去添加;
    foreach (DataRow row in ds.Tables[0].Rows)
                    {                    TreeNode newNode = new TreeNode("<input type=\"checkbox\" " + " " + this.selectorg + " id=\"" + row["AreaShortName"].ToString() + "\" value=\"" + row["AreaName"].ToString().Trim() + "\" onclick=\"javascript:CheckNode(this,'D')\"/>" + row["AreaName"].ToString().Trim(), row["AreaShortName"].ToString().Trim());
    ...
    ...
    }
    这是CheckNode事件:
    function CheckNode(checkBox,dataType)
    {
        if (checkBox.checked==true)
        {
           var  onlyflag='<%=this.only%>'; 
           if(onlyflag==1&&document.all.item ("txtField").value!="")
          {
               checkBox.checked=false; 
              alert("只能选择一个"); 
               return; 
          }  
           
        //添加
         document.all.item("txtField").value=document.all.item("txtField").value + checkBox.id+"|"+checkBox.value+"|"+dataType+ ",";
         //alert(document.all.item("txtField").value);
         ToList();
        }
        if (checkBox.checked==false)
        {
        //删除
        str=checkBox.id+"|"+checkBox.value+"|"+dataType+ ","
        document.all.item("txtField").value=document.all.item("txtField").value.replace(str,"");
        //alert(document.all.item("txtField").value);
        ToList();
        }
    }
      

  2.   

    楼上的guodawu($)是不是用ajax实现的啊,能不能把树这部分的代码发给我啊?谢谢,
    [email protected]
      

  3.   

    现在因为数据量大,正在写ajax动态读取的树,但前边必须有checkbox
      

  4.   

    如果你用的是微软的那颗TreeView的话,那这颗本来就自带了,只要把相关属性设置一下就行了
      

  5.   

    怎样在javascript里边写checkbox属性呢
      

  6.   

    怎样在javascript里边写checkbox属性呢
      

  7.   

    呵呵,蒙出来了,蒙对了,谁有treeview的sdk啊?