Generate JSON from SQL (PHP) for TreeGrid

Hi!
I would like to generate TreeGrid JSON from SQL (PHP).

My mySQL table looks something like:
id, path, filename, parentId
1,/Filename.txt,Filename.txt,NULL
2,/myFolder,myFolder,NULL
3,/xFilename.txt,xFilename.txt,NULL
4,/,myFolder/mySubFolder,mySubFolder,2
5,/,myFolder/subFilename.txt,subFilename.txt,2
6,/,myFolder/mySubFolder2,mySubFolder2,2
7,/,myFolder/mySubFolder/Pic.jpg,Pic.jpg,4

What I would like is generated JSON like the example below.
docs.dhtmlx.com/treegrid__treeg … ation.html

I have searched the documentation, but cannot find any way to generate structured treegrid JSON.

Q1: Can you show me an example of how this can be achieved (preferably with example DB structure).
Q2: How can I use TreeGridGroupConnector and JSON output?

Unfortunately dhtmlxConnector for the treegrid does not support the output in the json format.

Thank you for the reply!

If I am to generate TreeGrid XML from SQL (PHP) and my mySQL table looks something like:

id, path, filename, parentId
1,/Filename.txt,Filename.txt,NULL
2,/myFolder,myFolder,NULL
3,/xFilename.txt,xFilename.txt,NULL
4,/,myFolder/mySubFolder,mySubFolder,2
5,/,myFolder/subFilename.txt,subFilename.txt,2
6,/,myFolder/mySubFolder2,mySubFolder2,2
7,/,myFolder/mySubFolder/Pic.jpg,Pic.jpg,4

Would that work?
What data is expected in the parentId column?

Can you show me an example of how this can be achieved including example DB structure?

data of the “parentId” column should refer to the “id” of the parent row.
You can find ready working examples in the dhtmlxConnector package in the “samples/treegrid” directory.

Thanks! :slight_smile: