This is a migrated thread and some comments may be shown as answers.

Hierarchical Grid linking child to parent DataSource and saving as a JSON Object

3 Answers 218 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Augustin
Top achievements
Rank 1
Augustin asked on 29 Apr 2016, 07:34 AM
Morning, guys!
I`m pretty new to Kendo UI and yesterday I've encountered a problem which seems to be impossible for me to solve. Basically, I've got a Kendo hierarchical grid where I can add a new record for both parent and children by clicking a button. It looks something like this: http://jsbin.com/ubiruc/12/edit?html,js,output . I'm caught with 2 problems:
1) At the start, my whole grid is empty. If I add rows and then their details, all fine. But if I add a row, its details and after that another row in the main grid, the added details for first parent disappears. 

2) Stuck on how to save the whole structure in a JSON Object after I finished adding my wanted records.
Hope someone can help me out with this as I've been searching the internet for over 6 hours and nothing. Thanks in advance, have a great day!

3 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 03 May 2016, 07:18 AM
Hi Gabriel,

With respect to:

Question 1: We can hardly help you unless we see source code showing what you are doing. Can you  attach your page here? Either raw or Kendo Dojo.

Question 2: You may want to take a look at the persist state functionality.

Regards,
Genady Sergeev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Augustin
Top achievements
Rank 1
answered on 03 May 2016, 04:44 PM

http://dojo.telerik.com/IGafI

 

Here`s the link with the problem. Whenever i click Add new record in the main table, I want the child grid`s data to be saved (now if i click Add new record, all children`s data is removed). Also, when i finish adding new rows, I want to save the whole data source and post it to my backend.

0
Alex Gyoshev
Telerik team
answered on 06 May 2016, 07:16 AM

Hello Augustin,

When the parent grid is refreshed (by adding new children), all child grids are removed. Thus, you need to persist the data while it is edited, either by syncing it to the server or by maintaining a client-side data storage that will be synchronized when the data is finished editing. Both can be achieved by configuring the child datasource, either by binding it to server methods, or to the client-side cache. The first approach is recommended, as the latter requires identifying records prior to their saving, but here is a Dojo that shows the latter approach.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Augustin
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Augustin
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Share this question
or