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.