3

I have json data return from server and it has property of 'parent', I want that node to be the parent of node create,edit and delete.

so the output will be the first level is "admin" ,since produce parent is null I want to put under "admin" , then the nodes "create,update and delete" are under "produce" level. but I am having problem on how to achieve this in fancytree ?.

expected output looks like this

--Admin
|
|
| --produce
|     |
|      --create
|     |
|      --edit
|     |
|      --delete
|--seafood
     |
      --create
     |
      --edit
     |
      -delete

--Superadmin
|
|
| --produce
|     |
|      --create
|     |
|      --edit
|     |
|      --delete
|--seafood
     |
      --create
     |
      --edit
     |
      -delete

here is the data

{
   "roles":[
      {
         "id":1,
         "title":"Produce",
         "level":"01",
         "parent":null
      },
      {
         "id":2,
         "title":"create",
         "level":"0101",
         "parent":"1"
      },
      {
         "id":3,
         "title":"edit",
         "level":"0102",
         "parent":"1"
      },
      {
         "id":4,
         "title":"delete",
         "level":"010203",
         "parent":"1"
      },
      {
         "id":5,
         "title":"Seafood",
         "level":"02",
         "parent":null
      },
      {
         "id":6,
         "title":"create",
         "level":"0201",
         "parent":"5"
      },
      {
         "id":7,
         "title":"edit",
         "level":"0202",
         "parent":"5"
      },
      {
         "id":8,
         "title":"delete",
         "level":"0203",
         "parent":"5"
      }
   ],
   "groups":[
      {
         "id":1,
         "role":"admin"
      },
      {
         "id":2,
         "role":"superadmin"
      },
      {
         "id":3,
         "role":"purchasing"
      },
      {
         "id":4,
         "role":"warehouse"
      }
   ]
}
jemz
  • 4,987
  • 18
  • 62
  • 102

0 Answers0