zoukankan      html  css  js  c++  java
  • 下拉框 tree 基于 EasyUi

    public string DataTableToJson()
    		{
    			string dataJson = "";
    			string temp = "";
    			string tempChildren = "";
    			int id = 0;
    			int idChildren = 0;
    			DataTable dt = GJPDbHelper.DAL.ExecuteDataSet("select distinct  品牌,类型 from dbo.AIRB_MMTREE where treeType='1'").Tables[0];
    			if (dt.Rows.Count > 0)
    			{
    				dataJson = "[";
    				foreach (System.Data.DataRow dr in dt.Rows)
    				{
    					if (temp == "" || temp != dr[0].ToString())
    					{
    						if (id == 0)
    						{
    							id++;
    							idChildren = 0;
    							idChildren++;
    							temp = dr[0].ToString();
    							tempChildren = dr[1].ToString();
    							dataJson = dataJson + "{"id":" + id + ","text":"" + dr[0] + "","children":[{"id":" + Convert.ToInt32(id.ToString()+idChildren.ToString()) + ","text":"" + dr[1] + ""}";
    						}
    						else
    						{
    							id++;
    							idChildren = 0;
    							idChildren++;
    							temp = dr[0].ToString();
    							tempChildren = dr[1].ToString();
    							dataJson = dataJson + "]},{"id":" + id + ","text":"" + dr[0] + "","children":[{"id":" + Convert.ToInt32(id.ToString() + idChildren.ToString()) + ","text":"" + dr[1] + ""}";
    						}
    					}
    					else
    					{
    						idChildren++;
    						dataJson = dataJson + ",{"id":" + Convert.ToInt32(id.ToString() + idChildren.ToString()) + ","text":"" + dr[1] + ""}";
    					}
    				}
    				dataJson = dataJson + "]}]";
    			}
    			return dataJson;
    		}
    function BindRoleList(value) {
    	        $(value).combotree({
    	            data: <%=DataTableToJson()%>,
    			    //url: '/DesktopModules/ARB_OrgSys/GetOrgList.ashx',
    			    valueField: 'id',
    			    textField: 'text',
    			    multiple:true
    			});
            }
    	    $(document).ready(function () {
                BindRoleList("#cc");
                $("#cc").combobox({
                    onChange: function (n,o) {
                        document.getElementById("<%=tree.ClientID%>").value=$("#cc").combotree("getText");
                    }
     
                });
                
            });


    <input id="cc" class="easyui-combotree" style=" 100%" />
    
    再三须慎意,第一莫欺心
  • 相关阅读:
    使用CSS画三角形
    Hello World!
    python学习四(处理数据)
    python学习三(数据保存到文件)
    python学习二(文件与异常)
    python学习一(Python中的列表)
    Hadoop 解除 “Name node is in safe mode”(转)
    Java NIO开发需要注意的陷阱(转)
    Java NIO基本使用介绍
    如何设计企业移动应用 by宋凯
  • 原文地址:https://www.cnblogs.com/otsf/p/8805571.html
Copyright © 2011-2022 走看看