JQuery EasyUI(48)

                 第三十七章: ComboTree(树型下拉框)组件

学习要点:

  1. 加载方式
  2. 属性列表
  3. 方法列表

 一、加载方式:

//class加载方式:

<!DOCTYPE html>
<html>
  <head>
    <title>JQuery Easy UI</title>
    <meta charset="utf-8"/>
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>     
    <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>     
    <script type="text/javascript" src="js/index.js"></script> 
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css"/>  
    <style>
        .textbox{
            height:200px;
            margin:0;
            padding:0 2px;
            box-sizing:content-box;
       }
    </style>            
</head>
  <body>
      <select class="easyui-combotree" style="width:20px;" data-options="url:tree.json"></select>
      <input type="button" value="按钮" onclick="abc();">
  </body>
</html>
//tree.json
[
  { 
   "id":1,
   "text":"系统管理",
   "iconCls":"icon-save",
   "children":[
        {
           "text":"主机信息", 
           "state":"closed",         
           "children":[
               {
                 "text":"版本信息",          
               },
               {
                 "text":"数据库信息",          
               }
                    ];                    
         },
        {
           "text":"更新信息",          
         },
        {
           "text":"程序信息",          
         }
            ];
   }
  {
   "id":2,
   "text":"会员管理",
   "children":[
        {
           "id":"7",            
           "text":"新增会员",          
         },
        {
           "text":"审核会员",          
         }
            ];
   }
]

 //JS加载方式:

<!DOCTYPE html>
<html>
  <head>
    <title>JQuery Easy UI</title>
    <meta charset="utf-8"/>
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>     
    <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>     
    <script type="text/javascript" src="js/index.js"></script> 
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css"/> 
    <style>
        .textbox{
            height:200px;
            margin:0;
            padding:0 2px;
            box-sizing:content-box;
       }
    </style>             
</head>
  <body>
    <input type="text" id="box">
    <input type="button" value="按钮" onclick="abc();">   
  </body>
</html>
$(function(){
    $('#box').combotree({
     url:'tree.json',
     });
});

function abc(){

}

 

二、属性列表:

ComboTree属性
属性名类型说明
editableboolean定义用户是否直接输入文本到字段中,默认为false。

//属性列表,树型下拉框属性扩展自combo(自定义下拉框)和tree(树型控件)。

PS:该事件的属性完全继承自combo(自定义下拉框)和tree(树型控件)。

<!DOCTYPE html>
<html>
  <head>
    <title>JQuery Easy UI</title>
    <meta charset="utf-8"/>
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>     
    <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>     
    <script type="text/javascript" src="js/index.js"></script> 
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css"/> 
    <style>
        .textbox{
            height:200px;
            margin:0;
            padding:0 2px;
            box-sizing:content-box;
       }
    </style>             
</head>
  <body>
   <input type="text" id="box">
   <input type="button" value="按钮" onclick="abc();">   
  </body>
</html>
$(function(){
    $('#box').combotree({
     url:'tree.json',
     required:true,
     editable:true,
     });
});

function abc(){

}

 

三、方法列表:

树型下拉框方法扩展自combo(自定义下拉框)

ComboTree方法
方法名参数说明
optionsnone返回属性对象。
treenone返回树型对象。
loadDatadata读取本地树型数据。
reloadurl再次请求远程树数据。通过'url'参数重写原始URL值。
clearnone清空控件的值。
setValuesvalues设置组件值数组。
setValuevalue设置组件值。
<!DOCTYPE html>
<html>
  <head>
    <title>JQuery Easy UI</title>
    <meta charset="utf-8"/>
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>     
    <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>     
    <script type="text/javascript" src="js/index.js"></script> 
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css"/> 
    <style>
        .textbox{
            height:200px;
            margin:0;
            padding:0 2px;
            box-sizing:content-box;
       }
    </style>             
</head>
  <body>
   <input type="text" id="box">
   <input type="button" value="按钮" onclick="abc();">   
  </body>
</html>
$(function(){
    $('#box').combotree({
     url:'tree.json',
     required:true,
     editable:true,
     });
});

function abc(){

    /*
    var t = $('#box').combotree('tree');
    console.log(t.tree('getSelect'));


    $('#box').comtree('loadData',[
          {
           text:'加载',
          }
     ]);   

    $('#box').combotree('reload');

    $('#box').combotree('clear');

    $('#box').combotree('setValue',1);

    $('#box').combotree('setValues',[1,2,'abc']);

    */
}

 

作者:Roger_CoderLife

链接:https://blog.youkuaiyun.com/Roger_CoderLife/article/details/103867685

本文根据网易云课堂JQuery EasyUI视频教程翻译成文档,转载请注明原文出处,欢迎转载

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值