Example of using Easyui Combotree

Source: Internet
Author: User

First, View:

1. Defining an input control

<input id= "ParentID" name= "ParentID" >

2. Binding Combotree

$ (' #ParentId '). Combotree ({url: "/action/getmenutreedata/", Method: "Post", Lines:true,required:true,onclick: function (node) {
Automatically generates the sort number $.post ("/action/getmenudisorder/", {pId:node.id}, function (data) {$ ("#DisOrder"). val (data);});
Automatically generates the current level $.post ("/action/getmenudislevel/", {pId:node.id}, function (data) {$ ("#DisLevel"). val (data);});});

Second, Controller:

[Httppost]public actionresult Getmenutreedata () {//fetch from the data dictionary the ID number corresponding to the menu var dic = _dictionaryservice.single (O-O. Name = = "Menu" && o.isdeleted = = False); var menuId = dic.  id;//Query all menu information var menus = _actionservice.where (o = o.isdeleted = False && O.operationtype = MenuId && O.isshow = = True, O = O.disorder). ToList ();//Get root node information RSCC.Model.TreeNode rootNode = _actionservice.single (o = = O.parentid = 0). Tonode ();//3, depending on the ID of the root node, queries all of its child nodes Rootnode.children = fillsonnodes (menus, rootnode.id); return Content ("[" + Operationcontext.tojson (RootNode) + "]");}

<summary>///Recursive generation of child node collections//</summary>///<param name= "Listpermission" ></param>///< param name= "ParentID" ></param>///<RETURNS></RETURNS>LIST<RSCC. Model.treenode> Fillsonnodes (LIST<RSCC. model.action> list, int parentid) {LIST<RSCC. model.treenode> sonnodes = null;//Loop Permission collection, find child permissions foreach (RSCC. Model.action m in list) {//Find child permissions if (M.parentid = = ParentID) {//Instantiate child node collection if (sonnodes = = null) Sonnodes = new LIST<RSCC. Model.treenode> ();//Transfer Child permissions to child nodes RSCC.Model.TreeNode Sonnode = M.tonode ();//Add child nodes to the child Nodes Collection Sonnodes.add (sonnode);// Recursively finds child node sets for child nodes Sonnode.children = fillsonnodes (list, sonnode.id);}} return sonnodes;}

Third, the display effect:

Example of using Easyui Combotree

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.