Datasource with master and detail in one transaction

11 posts, 0 answers
  1. Jaap
    Jaap avatar
    96 posts
    Member since:
    Oct 2012

    Posted 13 Feb 2012 Link to this post

    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
  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 13 Feb 2012 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Jaap
    Jaap avatar
    96 posts
    Member since:
    Oct 2012

    Posted 14 Feb 2012 Link to this post

    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
  5. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 14 Feb 2012 Link to this post

    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!
  6. Psmontte
    Psmontte avatar
    4 posts
    Member since:
    Dec 2011

    Posted 09 Jun 2012 Link to this post

    Has anybody got success with this. If possible, kindly share code for any workaround that you have found.
  7. Psmontte
    Psmontte avatar
    4 posts
    Member since:
    Dec 2011

    Posted 10 Jun 2012 Link to this post

    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?
  8. Drew
    Drew avatar
    5 posts
    Member since:
    Jun 2012

    Posted 27 Jun 2012 Link to this post

    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;
  9. Psmontte
    Psmontte avatar
    4 posts
    Member since:
    Dec 2011

    Posted 03 Jul 2012 Link to this post

    Due to lack of documentation & KnockoutJS support we decided to chose another competing product over KendoUI.
  10. Jean
    Jean avatar
    4 posts
    Member since:
    Jun 2012

    Posted 14 Jul 2012 Link to this post

    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.
  11. Robin
    Robin avatar
    46 posts
    Member since:
    Jul 2012

    Posted 18 Jul 2012 Link to this post

    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 ?
  12. Jean
    Jean avatar
    4 posts
    Member since:
    Jun 2012

    Posted 19 Jul 2012 Link to this post

    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.
Back to Top
Kendo UI is VS 2017 Ready