sample of jstree ajax call code farm

Solutions on MaxInterview for sample of jstree ajax call code farm by the best coders in the world

showing results for - "sample of jstree ajax call code farm"
Mía
17 Jul 2020
1[HttpPost]
2public JsonResult GetTreeNode(Dictionary<string,string> search)
3{           
4    List<TreeNode> tree = new List<TreeNode>();
5    tree.Add(new TreeNode() {id="1",text="",state=new TreeState() { } });
6    if(search.ContainsKey("str"))
7    {
8        //Do your search by name here
9        //Format return is List<string> of all Id include with parent id
10        //Please make sure the parent id is exist
11        //Format ["idA","idAChild1","idAChild2","idAChild2Child1"]
12        return Json(tree.Select(x=> x.id).ToList());
13    } else if(search.ContainsKey("Parentid"))
14    {
15        // do your search server side here
16        //Format is List<TreeNode>
17        return Json(tree);
18    }
19  
20}
21Client Side Script jstree
22var url ="/controllerName/GetTreeNode";
23$("#treenode").jstree({
24       "core": {
25           "data": {
26               "url": url,
27               "type":"post",
28               "data"function (node{
29                   return { "ParentId": node.id };
30               }
31           }
32       },
33       "search": {        
34           "show_only_matches"true,
35           ajax: {
36               "url": url,
37               "type""post",
38               "data"function (str{
39                   return { "str": str };
40 
41               }        
42           }
43       },
44       "plugins": ["search"],
45   });
46   var searching = false;
47   $('#datasearch').keyup(function ({
48 
49       if (!searching) {
50           searching = true;
51           setTimeout(function ({
52               searching = false;
53               var v = $('#datasearch').val();
54               $("#treenode").jstree(true).search(v);         
55        
56            }, 1000);
57       }
58 
59   });
60
Franco
10 Mar 2016
1public class TreeState
2   {    
3 
4       public bool loaded { set; get; }
5       public bool opened { set; get; }
6       public bool selected { set; get; }
7       public bool disbled { set; get; }
8
Yannik
16 Jun 2020
1$("#treenode").jstree({
2       "core": {
3           "data": {
4               "url": url,
5               "type":"post",
6               "data"function (node{
7                   return { "ParentId": node.id };
8               }
9           }
10       },
11       "search": {        
12           "show_only_matches"true,
13           ajax: {
14               "url": url,
15               "type""post",
16               "data"function (str{
17                   return { "str": str };
18 
19               }        
20           }
21       },
22       "plugins": ["search"],
23   });
24   var searching = false;
25   $('#datasearch').keyup(function ({
26 
27       if (!searching) {
28           searching = true;
29           setTimeout(function ({
30               searching = false;
31               var v = $('#datasearch').val();
32               $("#treenode").jstree(true).search(v);         
33        
34            }, 1000);
35       }
36 
37   });