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

Datasource with master and detail in one transaction

14 Answers 389 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Jaap
Top achievements
Rank 2
Jaap asked on 13 Feb 2012, 08:58 AM
Hello,

How to handle a master - detail situation with datasources?
Of course I can use two separate datasource to read the data from the server.
But how to update the data to the server in one transaction?
In that case you would want to have one POST request to the server per master record including it's details.
But I am not aware of the ability to setup such relation between datasources.
Ideally you want to have such JSON object:
{ Field1: xxx, Field2: yyy, Details: [{ DetField1: aa, DetField2: bb }, { DetField1: cc, DetField2: dd }] }

Any ideas?

Regards, Jaap

14 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 13 Feb 2012, 03:52 PM
Hi Jaap,

Unfortunately, Model relations are not currently supported. Therefore, a separate requests for master and child items will be required.

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jaap
Top achievements
Rank 2
answered on 14 Feb 2012, 09:24 AM
Hi Rosen,

What whould happen if a datasource reads this result from the server:
{ Field1: xxx, Field2: yyy, Details: [{ DetField1: aa, DetField2: bb }, { DetField1: cc, DetField2: dd }] }

Whould the datasource accept this and in fact that a field will contain an array of objects?
Any idea if that will work. Of course I don't expect you support this in your widgets like the gird. But if the datasource accepts this, I can use that array as a local source for another datasource to display it in a grid and after manupilating the data save if back in the field of the original datasource and sync it to the server.
If you have no experience with this, I will try it myself.

Regards, Jaap
0
Rosen
Telerik team
answered on 14 Feb 2012, 01:49 PM
Hi Jaap,

Indeed, the DataSource will load the records with such structure. However, the changes in the inner array will not be tracked, therefore when the parent items are submitted the changes of the inner array will not be present. Thus, you will need somehow to manually sync the parent and inner array when updated.

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Psmontte
Top achievements
Rank 1
answered on 09 Jun 2012, 07:50 AM
Has anybody got success with this. If possible, kindly share code for any workaround that you have found.
0
Psmontte
Top achievements
Rank 1
answered on 10 Jun 2012, 06:21 AM
In your upcoming Q2 release have mentioned "support for hierarchical and relational data in the DataSource" in Q2 release, will that support master/detail in one transaction?
0
Drew
Top achievements
Rank 1
answered on 27 Jun 2012, 05:29 PM
I used the parameterMap. Turns out to be a very "hardcoded" solution, but it works.
Use it to pass any extra detail lists

Because it's not part of the model, you might have to create a function that goes through the dirty data and grabs the items that need updating.

I also had to convert the given object to just a plain object

var oData = new Object();
for (ii in DETAIL)
   oData(ii) = DETAIL(ii);
DETAIL = oData;
0
Psmontte
Top achievements
Rank 1
answered on 03 Jul 2012, 11:45 AM
Due to lack of documentation & KnockoutJS support we decided to chose another competing product over KendoUI.
0
Jean
Top achievements
Rank 1
answered on 14 Jul 2012, 11:15 AM
Nobody has an acceptable solution for this problem ?
How can I make a simple invoice form for example ? A main part with customer informations and an editable grid with the detail.
If this simple problem has an acceptable solution, I choose Kendoui tomorow :)
Thanks.
0
Robin
Top achievements
Rank 1
answered on 18 Jul 2012, 08:15 PM
If all you need is an editable grid for use with the details, and static information in the header, why not make two server requests, one for the customer information to display at the top (MVVM) and a grid on the bottom using it's own datasource for the editable details ?
0
Jean
Top achievements
Rank 1
answered on 19 Jul 2012, 07:03 AM
It's a bit more complicated.
The information in the header is not static. Imagine an Invoice. You enter informations in the main part (date, customer, etc.) AND you enter some lines in the detail.
And when you click Ok or Save, it should be done in a transaction. The serveur must receive all the information in a blick, the master and the detail.
But imagine now you modify this invoice and you delete a line in the detail grid, the detail line should not be deleted immediately in the database by the server but when the user click Ok, on an transaction... So, you cannot use the datasource as it should.
Of course, we  can imagine a solution where a "change" event memorize the deleted or changed or added lines etc. But in this case, why should I use a framework where I have to code everything ?
For the kind of application I work for, in my opinion, it's the most important problem.
0
Renu
Top achievements
Rank 1
answered on 07 Jan 2018, 05:13 AM

Hi,

have you got any workarounds for this issue?? 

0
Nencho
Telerik team
answered on 10 Jan 2018, 01:22 PM
Hello Renu,

Having in mind that this thread is quite old (6 years), I would like to ask you to elaborate a bit more on your current scenario and what your are trying to achieve.

Regards,
Nencho
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Renu
Top achievements
Rank 1
answered on 13 Jan 2018, 05:03 AM

How to handle a master - detail situation with datasources?
Of course I can use two separate datasource to read the data from the server.
But how to update the data to the server in one transaction?
In that case you would want to have one POST request to the server per master record including it's details.

Recently, one of your executive has replied me that I can use the Data function of the Read action to pass additional data.

I think I can pass the master details in an array using the above mentioned method. But how can i retrieve those values in controller?

Can you show me an example for the same?

0
Viktor Tachev
Telerik team
answered on 18 Jan 2018, 09:23 AM
Hello Renu,

The Data function can be used to send additional data to the server. However, sending complex objects and entire data sets is not recommended. 

As my colleague has suggested in the support ticket you have submitted the recommended approach in hierarchical scenarios is to use a separate dataSource for the master and detail Grid. Furthermore, this makes more sense as usually the parent and child grid will show data from separate tables in the database that are related. In that scenario the Data() method can be used in the child grid to send the parent id to the read action. 


Regards,
Viktor Tachev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Data Source
Asked by
Jaap
Top achievements
Rank 2
Answers by
Rosen
Telerik team
Jaap
Top achievements
Rank 2
Psmontte
Top achievements
Rank 1
Drew
Top achievements
Rank 1
Jean
Top achievements
Rank 1
Robin
Top achievements
Rank 1
Renu
Top achievements
Rank 1
Nencho
Telerik team
Viktor Tachev
Telerik team
Share this question
or