I have the hierarchy of an organization in the SQL database. It looks like this -
Main Manager
Manager - 1
Manager - 1.1
Manager - 1.1.1
Manager - 2
Manager - 2.1
Manager - 2.1.1
Manager - 2.2
etc.
I want to fetch the values in the database and convert to a jquery object just like the example below.
How can I fetch the sql data in the database in hierarchical order and create a jquery object like in the example below?
var data = { Name: "Manager - 1",
ID: "1",
children: [ {
Name: "Manager - 1.1",
ID: "1.1",
children: [ {
Name: "Manager - 1.1.1",
ID: "1.1.1"}
]
Name: "Manager - 1.2",
ID: "1.2",
children: [ {
Name: "Manager - 1.2.1",
ID: "1"}
]
}
]
};