jQuery UI Widgets › Forums › TreeGrid › use hierarchy for json sub structure
Tagged: Angular tree grid, javascript treegrid, jquery tree grid, jqwidgets, tree grid, treegrid control, treegrid hierarchy
This topic contains 1 reply, has 2 voices, and was last updated by Peter Stoev 9 years, 1 month ago.
-
Author
-
Hello,
I wish to display in the same TreeGrid the mains records (Boob name, Author) and collapsed comments.
Here is my code. The lines corresponding to appears when clicking on expand-arrow, but nothing is displayed in cells. What is wrong ?var books = [ { ID: 2, book: "I live", author: "Fuller", comments: [ {ID2: 8, date: "2014-03-05 00:00:00", text: "bad book"}, {ID2: 21, date: "2014-08-10 00:00:00", text: "read by emma"} ] }, { ID: 5, book: "I die", author: "Buchanan", comments: [ {ID2: 6, date: "2013-10-17 00:00:00", text: "good book"}] } ]; //// prepare the data var source = { dataType: "json", dataFields: [ { name: 'main.ID',type: 'number', map:'ID'}, { name: 'main.book',type: 'string', map: 'book'}, { name: 'main.author',type: 'string',map: 'author'}, { name: 'comments'}, { name: 'comments.ID2',type: 'number',map:'comments>ID2'}, { name: 'comments.date',type: 'date',map:'comments>date'}, { name: 'comments.text',type: 'string',map:'comments>text' } ], hierarchy: { root:'comments'}, id: 'ID', localData: books }; var dataAdapter = new $.jqx.dataAdapter(source); // create Tree Grid $("#treeGrid").jqxTreeGrid({ width: 680, source: dataAdapter, sortable: true, theme: 'energyblue', columns: [ { text: 'ID', dataField: 'main.ID', width: 70 }, { text: 'book', dataField: 'main.book', width: 100 }, { text: 'author', dataField: 'main.author', width: 120 }, { text: 'comments-ID2', dataField: 'comments.ID2', width: 120 }, { text: 'comments-date', dataField: 'comments.date', width: 120 }, { text: 'comments-text', dataField: 'comments.text', width: 120 } ] });
Best regards.
Hi foulques.nera,
The structure of the hierarchy should be the same for parents and children as shown in the http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxtreegrid/javascript-tree-grid-binding-to-nested-json.htm?arctic
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.