Tree with check box (checkbox)

Source: Internet
Author: User

The official examples are simple examples of how to turn JSON data into a tree.
This example can meet our general needs. Many times we need to use a tree with a checkbox.
In fact, adding a checkbox is simple, just add the checked entry (for True/false) to the returned JSON data. To achieve what we want to select the parent node of the checkbox, the automatic selection of the neutron node is also very simple, just add the following section of code can be. View plain Copy to clipboard print? Tree.on (' Checkchange ',  function (node, checked)  {                node.expand ();                node.attributes.checked = checked;                node.eachchild (function (child)  {                    child.ui.togglecheck (checked);                   child.attributes.checked  = checked;                    child.fireevent (' Checkchange ',  child, checked);                });            }, tree);   

Tree.on (' Checkchange ', Function (node, checked) {   
		node.expand ();   
		node.attributes.checked = checked;   
		Node.eachchild (function (child) {   
			Child.ui.toggleCheck (checked);   
			child.attributes.checked = checked;   
			Child.fireevent (' Checkchange ', child, checked);   
		});   
	 

Demo (Demo) address at the end of the article.

The effect chart is as follows:

Source code includes 0005_checkbox_reorder.html,0005_checkbox_reorder_tree.php.

0005_checkbox_reorder.html View plain Copy to clipboard print?

 

0005_checkbox_reorder_tree.jsp [{"CLS": "Folder", "id": "leaf": False,checked:false, "Children": [{"CLS": "File", " ID ": One," leaf ": True,checked:false," children ": null," text ":" S600 "},{" CLS ":" File "," id ":" Leaf ": true,checked: False, "Children": null, "text": "SLK200"}], "text": "Benz"}]

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.