dojo中建立包含節點複選框的樹形(CheckBoxTree),dojocheckboxtree

來源:互聯網
上載者:User

dojo中建立包含節點複選框的樹形(CheckBoxTree),dojocheckboxtree

    樹形結構是介面設計程中常見的組件,在代碼實現時有很多方法,但由於設計到節點的父子關係和dom節點操作,實現起來比較複雜。dojo中提供了帶複選框的樹形組件CheckBoxTree,使用時只需建立對應的執行個體即可輕鬆實現此功能。
    組件對應的html檔案代碼如下:

<div> <div dojoType="dijit.Dialog" dojoAttachPoint="testList" title="${title}" style="width: 100px;height:200px">     <div dojoType="dijit.layout.ContentPane" region="center" style="height:180px;">    <div dojoAttachPoint="testTree" style></div>   </div> </div></div>


    調用樹形組件的js檔案中需添加引用:

dojo.require("dojox.layout.ContentPane");dojo.require("tmpdir.CheckBoxTree");dojo.require("tmpdir.CheckBoxStoreModel");dojo.require("dojo.data.ItemFileWriteStore");


    調用過程為:

var data = {identifier: "id",label: "name",items: content};//節點已id為唯一標示,name為節點顯示欄位//content為json對象,格式為[id:'id',name:'name',items:[]]var store = new dojo.data.ItemFileWriteStore({data: data});var model = new tmpdir.CheckBoxStoreModel({    store: store,    childrenAttrs: ["items"],    query: {        id: '*'    }});var tree = new tmpdir.CheckBoxTree({    model: model,    showRoot: false,//是否顯示根節點    persist: false,//    openOnClick : true,//點擊時是否開啟樹形    branchIcons : false,//父節點是否顯示圖形    nodeIcons: false,//子節點是否顯示圖形    autoExpand: true//載入後是否自動延伸}, this.testTree);


 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.