а

TreeGrid Parse Problem


#1

Hello,

i am currently programming a treegrid.

the treegrid is filled with data in two steps. First, the structure is loaded. Thereafter, the products should be added to the categories.
I want to use the function parse (data, ‘js’) for that. it works, but the products are not created in the categories but in the root.

how is the parameter for the parend id?

example data:
“[
{“id”:“5d038da8d2a39399b2493423”,“active”:true,“number”:“10000”,“description”:“Erstes Testteil”,“parent_id”:“5d037a17d2a39399b24930d8”,“descriptions”:[{“lang”:“DE”,“description”:“Erstes Testteil”}],“unit”:“stk”,“attributes”:[],“number_subsystem”:“200000”},{“id”:“5d039101d2a39399b2493526”,“active”:true,“number”:“10001”,“description”:“Zweites Testteil”,“parent_id”:“5d037a17d2a39399b24930d8”,“descriptions”:[{“lang”:“DE”,“description”:“Zweites Testteil”}],“unit”:“stk”,“attributes”:[],“number_subsystem”:“200001”},{“id”:“5d039128d2a39399b2493534”,“active”:true,“number”:“10003”,“description”:“Drittes Testteil b”,“parent_id”:“5d0387b3d2a39399b24932eb”,“descriptions”:[{“lang”:“DE”,“description”:“Drittes Testteil”}],“unit”:“stk”,“attributes”:[],“number_subsystem”:“200002”}
]”


#2

Please, refer to the example of the supported treegrid json format of data:
https://docs.dhtmlx.com/treegrid__treegrid_initialization.html#json
Note, that the child nodes should nested in the parent node row string.

[{
	id: '1001',
	tree: {
		"value": "row A",
		"image": "folder.gif"
	},
	title: "A Time to Kill",
	name: "John Grisham",
	price: "12.99",
	status: "1",
	date: "05/01/1998",
	rows: [{
		id: 'sub_1001',
		tree: "subrowA",
		title: "Blood and Smoke",
		name: "Stephen King",
		price: "0",
		status: "1",
		date: "01/01/2000"
	}, {
		id: 'sub_1002',
		tree: "subrowB",
		title: "Blood and Smoke",
		name: "Stephen King",
		price: "0",
		status: "1",
		date: "01/01/2000"
	}]
}, {
	id: '1002',
	tree: "row B",
	title: "The Green Mile",
	name: "Stephen King",
	price: "11.10",
	status: "1",
	date: "01/01/1992"
}]

Here you can find a working example:
https://dhtmlx.com/docs/products/dhtmlxTreeGrid/samples/01_initialization_loading/07_treeGrid_json2.html