EasyUI creates an asynchronous Tree

Source: Internet
Author: User
@ AuthorYHC: when creating an asynchronous tree, each tree must have an & amp; #39; id & amp; #39; attribute. This attribute will be submitted back to the server to retrieve the child node data. view the Demo Tree [html] & lt; ulid & quot; tt & quot; class & quot; easyui-tree & quot; url & quot; tree2_g

@ Author YHC

When creating an asynchronous tree, each tree must have an 'id' attribute. This will be submitted back to the server to retrieve the data of the subnode.

 


View Demo

 

Create a Tree
[Html]

    Url = "tree2_getdata.php">

      Url = "tree2_getdata.php">
       

      Server code
      [Php]
      $ Id = isset ($ _ POST ['id'])? Intval ($ _ POST ['id']): 0;

      Include 'conn. php ';

      $ Result = array ();
      $ Rs = mysql_query ("select * from nodes where parentId = $ id ");
      While ($ row = mysql_fetch_array ($ rs )){
      $ Node = array ();
      $ Node ['id'] = $ row ['id'];
      $ Node ['text'] = $ row ['name'];
      $ Node ['state'] = has_child ($ row ['id'])? 'Closed ': 'Open ';
      Array_push ($ result, $ node );
      }

      Echo json_encode ($ result );

      Function has_child ($ id ){
      $ Rs = mysql_query ("select count (*) from nodes where parentId = $ id ");
      $ Row = mysql_fetch_array ($ rs );
      Return $ row [0]> 0? True: false;
      }

      Author: yhc13429826359

      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.