Home > Net >  Layui tree
Layui tree

Time:09-30

This is what meaning, don't layui. Js not this way?

CodePudding user response:

You go to the post in a tree structure declaration request is what operation

CodePudding user response:

reference 1/f, f * * KCSDN response:
you go to the post request in a tree structure declaration is what operation

I need the implementation to the operation of the database, need to post to the backstage

CodePudding user response:

refer to the second floor weixin_45226447 response:
Quote: reference 1/f, f * * KCSDN response:
you go to the post request in a tree structure declaration is what operation

The need to implement to the operation of the database, I need to post to the backstage

I am using layui framework, according to the layui website, js code is the latest but still showed no render method in the tree

CodePudding user response:

That you should post here according to the different operation to submit data
 
Tree. Render ({
Elem: '# test1'
To operate: function (obj) {
Var type=obj. Type;//get the operation type: add, edit, del
Var data=https://bbs.csdn.net/topics/obj.data;//get the data of the current node
Var elem=obj. Elem;//get the current node element

//Ajax operations
var id=data.id;//get the node index
If (type==='add') {//add node
//return key value
The return of 123;
} else if (type==='update') {//modify the node
The console. The log (elem. Find (' layui - tree - TXT '). The HTML ());//get the modified content
} else if (type==='del') {//delete node

};
}
});

CodePudding user response:

If is to dynamically bound data according to the format of the document to return after the json data to the data attribute
the data source properties option

CodePudding user response:

I know you said this was added to the database and delete, but the tree. The render method error, can't show a tree, so add and delete cannot undertake,

CodePudding user response:

I saw this layui official website, and then I used the use, prompt tree. The render is not the function can't find this method

CodePudding user response:

 public class TreeNode 
{
Public TreeNode () {children=new List (a); }
Public string title {get; The set; }
Public int id {get; The set; }
Public List The children {get; The set; }
Public string href {get; The set; }
Public bool spread the {get; The set; }=true;
Public bool @ checked the {get; The set; }=true;
Public bool disabled {get; The set; }
}

 
[HttpGet]
Public JsonResult GetTree ()
{
List The root=new List (a);

TreeNode node1=new TreeNode () {title="Parent1," id=1};
TreeNode 2=new TreeNode () {title="Parent2," id=2};

List Childen1=new List () {new TreeNode () {title="P1Child1", id=3}, new TreeNode () {title="P1Child2", id=4}};

List Childen2=new List () {new TreeNode () {title="P2Child1", id=5}, new TreeNode () {title="P2Child2", id=6}};

Node1. Children. AddRange (childen1);
2. Children. AddRange (childen2);

Root. The Add (node1);
Root. The Add (2);

Return a Json (root, JsonRequestBehavior. AllowGet);
}

 

<script SRC="https://bbs.csdn.net/topics/~/Scripts/layui/layui.js" & gt; </script>
<script>
Var treeData;
$.get ('/Home/GetTree ', function (data) {
TreeData=https://bbs.csdn.net/topics/data;
});
Layui. Use (' tree ', function () {
var tree=layui.tree;
Var inst=tree. Render ({
Elem: '# treeContainer',
Data: treeData
});
});
</script>


CodePudding user response:

Thank you, because I have a try and give you back to the

CodePudding user response:


Yes, still won't do! This should be a JS error! But I refer to the latest JS, but still won't do!

CodePudding user response:

CodePudding user response:

Use layui. Js not layui. All. Js

CodePudding user response:

And you look at your network has a request to the tree. The js

CodePudding user response:


I change layui js into the sample, and then how?

CodePudding user response:

Under your layui folder is not lay/modules this directory
All components are through the js loaded into the page in the directory

CodePudding user response:



CodePudding user response:

Directory structure is not suggested to adjust
If need to adjust according to the structure to the corresponding adjustment or you will call less than
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related