ligerui版本:1.1.0

在线测试例子:http://vazumi.net.s1.kingidc.net/example/comboboxtree.htm

截图:

ligerui下拉框加载tree的几个例子

代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title></title>
    <link href="../lib/ligerUI/skins/aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />        
    <script src="../lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="../lib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>
    <script src="../lib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script> 
    
 <script type="text/javascript">      
        $(function ()
        {
//-------------------------------------------------------------------------------------------
            $("#txt1").ligerComboBox({
                width: 200,
                selectBoxWidth: 200,
                selectBoxHeight: 200,
                textField:'text', valueField: 'id',treeLeafOnly:false,
                tree: { url: "/service/DataHandler.ashx?View=treeunit", checkbox: false,
                        textFieldName:"text",
                        idFieldName:"id",
                        parentIDFieldName:"pid"
                      }
            });
//-------------------------------------------------------------------------------------------    
            $("#txt2").ligerComboBox({
                width: 200,
                selectBoxWidth: 200,
                selectBoxHeight: 200, 
                textField:'text', valueField: 'id',treeLeafOnly:false,
                tree: { url: "/service/DataHandler.ashx?View=treeunit", checkbox: true,
                        textFieldName:"text",
                        idFieldName:"id",
                        parentIDFieldName:"pid"
                      }
            });                                
//-------------------------------------------------------------------------------------------
            $("#txt3").ligerComboBox({
                width: 200,
                selectBoxWidth: 200,
                selectBoxHeight: 200, 
                textField:'text', valueField: 'id',treeLeafOnly:false,
                tree: { url: "/service/DataHandler.ashx?View=treeunit", checkbox: false,
                        textFieldName:"text",
                        idFieldName:"id",
                        parentIDFieldName:"pid",
                        onSuccess:function(){
                           $(".l-expandable-close","#div3").click();
                           $("#txt3_val").val("");
                           $("#txt3").val("");
                        }
                      }
            });  
//-------------------------------------------------------------------------------------------
            $("#txt4").ligerComboBox({
                width: 200,
                selectBoxWidth: 200,
                selectBoxHeight: 200, 
                textField:'text', valueField: 'id',treeLeafOnly:false,
                tree: { url: "/service/DataHandler.ashx?View=treeunit", checkbox: true,
                        textFieldName:"text",
                        idFieldName:"id",
                        parentIDFieldName:"pid",
                        onSuccess:function(){
                           $(".l-expandable-close","#div4").click();
                        }
                      }
            }); 
//-------------------------------------------------------------------------------------------
            $("#txt5").ligerComboBox({
                width: 200,
                selectBoxWidth: 200,
                selectBoxHeight: 200, 
                textField:'text', valueField: 'id',treeLeafOnly:false,
                tree: { url: "/service/DataHandler.ashx?View=treeunit", checkbox: true,
                        textFieldName:"text",
                        idFieldName:"id",
                        parentIDFieldName:"pid",
                        onSuccess:function(){
                           $(".l-expandable-close","#div5").each(function ()  //这个选择写法判断的比较烂
                           {                               
                               if ($(this).next().next().next().text()=="总经理室")
                               {
                                    $(this).click();
                                    return;
                               }
                           });
                        }
                      }
            });
//-------------------------------------------------------------------------------------------                                                                     
        });                                      
    </script>                       
</head>
<body style="padding: 20px">
    <h3 style="padding:5px">ligerui 1.1.0 下拉树的几个例子</h3>
    <div style="float:left" /></div>
    <div style="float:left" /></div>
    <div style="float:left" /></div>
    <div style="float:left" /></div>
    <div style="float:left" /></div>
</body>
</html>

 说明:

json里面有玄机,有一个字段是 isexpand,值为false,透过这个东西,可以控制某个节点展开还是关闭

如果数据源不这么做,也有办法,例子里面3,4,5都是加载完数据再对tree展开或者关闭

完毕。

相关文章:

  • 2022-12-23
  • 2022-01-19
  • 2021-09-14
  • 2021-09-10
  • 2022-01-05
  • 2021-11-27
  • 2022-12-23
  • 2021-09-16
猜你喜欢
  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
相关资源
相似解决方案