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%" />
    
    再三须慎意,第一莫欺心
  • 相关阅读:
    Struts2.1.8 + Spring3.0+ Hibernate3.2整合笔记
    SSH整合之_架构的历史序列图
    Spring整合Hibernate笔记
    Oracle日志文件的管理与查看
    java调用Oracle存储存储过程
    Oracle PLSQL笔记(过程的创建和及调用)
    使用 Spring 2.5 TestContext 测试DAO层
    SpringBoot 启动慢的解决办法
    C++ CEF 浏览器中显示 Tooltip(标签中的 title 属性)
    Chromium CEF 2623 -- 支持 xp 的最后一个版本源码下载和编译步骤
  • 原文地址:https://www.cnblogs.com/otsf/p/8805571.html
Copyright © 2011-2022 走看看