jquery directory tree Plug-in wdtree use method

Source: Internet
Author: User


Wdtree is a lightweight jquery directory tree plug-in that supports multilevel directory selection, directory and file checkbox options, gets check box values, supports multiple configuration parameters customization, multiple callback function configurations, and can be loaded from other pages Ajax loading data.

How to use

To use this plugin, you need an HTML element, such as the following code:

<div id= "Tree" ></div>

And then call the plugin

var o = {

showcheck:true

//onnodeclick:function (item) {alert (item.text);},

};

O.data = Treedata;

$ ("#tree"). TreeView (O);

Get the element in the checkbox selection

$ ("#showchecked"). Click (function (e) {

var s=$ ("#tree"). Getcheckednodes ();

if (s!=null)

alert (S.join (","));

else

alert ("NULL");

});

Gets the currently selected element

$ ("#showcurrent"). Click (function (e) {

var s=$ ("#tree"). Getcurrentnode ();

if (s!=null)

alert (s.text);

else

alert ("Current node being nothing");

};

Configuration parameters

Configuration parameters supported by the data configuration

data:[{    id: "Node1",  //node id   

  text: "Node 1",  //node text for display.     value: "1",  //node value     showcheck:false, // Whether to show checkbox     checkstate:0, //checkbox checking  state. 0 for unchecked, 1 for partial checked, 2 for 

Checked.     haschildren:true, //if haschildren and complete set to  true, and childnodes is empty, tree will request server to

 get sub node.

    isexpand:false, //expand or collapse.

    complete:false, //see haschildren.     childnodes:[] // child nodes}] 

Other configuration parameters that are available

Cascadecheck:boolean Whether node being seleted leads to parent/sub node being.
Cbiconpath:string Checkbox image path.
clicktoggle:string Whether to toggle node when node clicked.
Showcheck:boolean Whether to show check box or not.
Theme:string Tree Theme. Three themes provided. ' Bbit-tree-lines ', ' bbit-tree-no-lines ' and ' bbit-tree-arrows '.
url:string URL for child nodes retrieving.


callback function

Oncheckboxclick (tree, item, status)
Fired when check box was clicked on.
Object Tree the Tree object.
Object item Node item clicked on.
Number status 1 for checked, 0 for unchecked.
Onnodeclick (tree, item)
Fired when a node was clicked on.
Object Tree the Tree object.
Object item Ndde item clicked on.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.