combotree(樹(shù)形下拉框)

含義

樹(shù)形下拉框結(jié)合選擇控件和下拉樹(shù)控件。它與combobox(下拉列表框)類(lèi)似,但是將下拉列表框的列表替換成了樹(shù)形控件。該控件支持樹(shù)狀態(tài)復(fù)選框,方便多選操作。

依賴

  • combo
  • tree

用法

標(biāo)簽創(chuàng)建

<select id="cc" class="easyui-combotree" style="width:200px;"   
        data-options="url:'get_data.php',required:true"></select>  

javascript創(chuàng)建

<input id="cc" value="01">  

    <input id="cc" value="01">
 
$('#cc').combotree({    
    url: 'get_data.php',    
    required: true   
}); 

屬性

屬性名 類(lèi)型 含義 默認(rèn)值
editable boolean 用戶是否可以直接輸入文本到字段中 false

樹(shù)形下拉框?qū)傩詳U(kuò)展自combo(自定義下拉框)和tree(樹(shù)形控件),樹(shù)形下拉框重寫(xiě)的屬性如下:

屬性名 類(lèi)型 含義 默認(rèn)值
editable boolean 用戶是否可以直接輸入文本到字段中 false

事件

該控件的事件完全繼承自combo(自定義下拉框)和tree(樹(shù)形控件)。

方法

方法名 參數(shù) 含義 列子
options none 返回屬性對(duì)象
tree none 返回樹(shù)形對(duì)象 var t = $('#cc').combotree('tree'); // 獲取樹(shù)對(duì)象var n = t.tree('getSelected'); // 獲取選擇的節(jié)點(diǎn)alert(n.text);
loadData data 讀取本地樹(shù)形數(shù)據(jù) $('#cc').combotree('loadData', [{id: 1,text: 'Languages',children: [{id: 11,text: 'Java'},{id: 12,text: 'C++'}]}]);
reload url 再次請(qǐng)求遠(yuǎn)程樹(shù)數(shù)據(jù)
clear none 情況控件的值
setValues values 設(shè)置組件值數(shù)組 $('#cc').combotree('setValues', [1,3,21]);
setValue value 設(shè)置組件值 $('#cc').combotree('setValue', 6);

樹(shù)形下拉框方法擴(kuò)展自combo(自定義下拉框),樹(shù)形下拉框新增和重寫(xiě)的方法如下:

方法名 參數(shù) 含義 列子
options none 返回屬性對(duì)象
tree none 返回樹(shù)形對(duì)象 var t = $('#cc').combotree('tree'); // 獲取樹(shù)對(duì)象var n = t.tree('getSelected'); // 獲取選擇的節(jié)點(diǎn)alert(n.text);
loadData data 讀取本地樹(shù)形數(shù)據(jù) $('#cc').combotree('loadData', [{id: 1,text: 'Languages',children: [{id: 11,text: 'Java'},{id: 12,text: 'C++'}]}]);
reload url 再次請(qǐng)求遠(yuǎn)程樹(shù)數(shù)據(jù)
clear none 情況控件的值
setValues values 設(shè)置組件值數(shù)組 $('#cc').combotree('setValues', [1,3,21]);
setValue value 設(shè)置組件值 $('#cc').combotree('setValue', 6);

我的demo

image
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>form-combotree - jQuery EasyUI Demo</title>
  <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
  <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
  <link rel="stylesheet" type="text/css" href="../demo.css">
  <script type="text/javascript" src="../../jquery.min.js"></script>
  <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
  <script type="text/javascript">
  $(function() {
    var data = [{
      id: 1,
      text: 'Languages',
      children: [{
        id: 11,
        text: 'Java'
      },{
        id: 12,
        text: 'C++'
      }]
    },{
      id: 2,
      text: 'book',
      children: [{
        id: 13,
        text: 'xxx1'
      },{
        id: 14,
        text: 'ccc'
      }]
    }];
    $('#cc').combotree({
        required: true
    });
    $('#cc').combotree('loadData',data );

    $('#cc1').combotree({
        required: true
    });

    $('#cc1').combotree('loadData',data );


    $('#cc2').combotree({
        required: true,
        multiple: true,
        height:50
    });

    $('#cc2').combotree('loadData',data );

  })
  function setvalue(){
      $.messager.prompt('SetValue','Please input the value(1,2,3,etc):',function(v){
        if (v){
          $('#cc1').combotree('setValue',v);
        }
      });
    }
  </script>
</head>
<body>
  <h2>Basic Form combotree </h2>
    <div style="margin:20px 0;"></div>
    <div class="easyui-panel" title="New Topic" style="width:400px">
        <div style="padding:10px 60px 20px 60px" >
          <div>combotree</div>
          <input id="cc" >
        </div>

        <div style="padding:10px 60px 20px 60px" >

          combotree action

          <div style="margin:20px 0;">
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="setvalue()">SetValue</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="alert('key:'+$('#cc1').combotree('getValue'))">GetValue</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#cc1').combotree('disable')">Disable</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#cc1').combotree('enable')">Enable</a>
          </div>
          <input id="cc1" >
        </div>

        <div style="padding:10px 60px 20px 60px" >
          <div>combotree multiple</div>
          <input id="cc2" >
        </div>



  </div>
</body>
</html>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容