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

Wrapping multiple data source saves into a single call

3 Answers 396 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 31 Dec 2013, 05:02 PM
We have a form with 3 tabs. Each tab has an editable grid in batchMode. We want to have a single save button on the page.

It will need to call the save of each grid. However, it appears the grid sync doesn't return a promise. 

What is the suggested way to do this, checking there were no errors in the first call before making the next. Does the sync event return error info? Is the sync event called even if there is an error? If would be great if sync returned a promise but it doesn't seem to. I'm not sure if I can wrap these in a jquery or underscore deferred in some way?

BOb

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 01 Jan 2014, 02:42 PM
Hello Bob,

It is not clear whether the three Grids are bound to the same data. If this is the case, then using a single shared Kendo UI DataSource instance is possible, which will allow you to use one sync() method call.

If the data is different, the using a single request to sync all three dataSource instances will require custom coding and manual Ajax requests. In my opinion such a complexity is highly unnecessary.

In case you need the DataSources to sync in a particular order, you can use their events to trigger syncing of the next instance, once the previous one has finished.

http://docs.kendoui.com/api/framework/datasource

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
dee
Top achievements
Rank 1
answered on 08 Jul 2016, 02:42 AM
[quote]Dimo said:
If the data is different, the using a single request to sync all three dataSource instances will require custom coding and manual Ajax requests. In my opinion such a complexity is highly unnecessary.
 

[/quote]

Hi Dimo,
I'm afraid I am facing a similar problem and need an advice.
Because of the UI limitations I am forced to use multiple listview controls on the same page. Each of the listviews would only have a one object bound from the initial array of objects.
I am not quite sure how to move on with the saving though cause would need to save them all at once.
At first I've thought that I'd need to be able to create a master datasource where each of it's items would be a separate datasource for each of the listviews, but so far I see that is not possible.

So currently I have an array of datasources, where datasource[i] would be bound to a listviews[i].

var products = [{ProductID:1, ProductName:"Prod1"}, {ProductID:2, ProductName:"Prod2"}]
                  var dataSources = [];
          var listViews = [];
          var dataSources[0] = new kendo.data.DataSource({
                data: products[0],
                schema: {
                  model: {
                    id: "ProductID",
                    fields: {
                      ProductID: { editable: false, nullable: true },
                      ProductName: { validation: { required: true} }
                    }
                  }
                }
              });
 
          var listViews[0] = $("#listView").kendoListView({
            dataSource: dataSources[0],
            template: kendo.template($("#template0").html()),
            editTemplate: kendo.template($("#editTemplate0").html())
          }).data("kendoListView");
           
            var listViews[1] = $("#listView").kendoListView({
            dataSource: dataSources[0],
            template: kendo.template($("#template1").html()),
            editTemplate: kendo.template($("#editTemplate1").html())
          }).data("kendoListView");
0
Dimo
Telerik team
answered on 08 Jul 2016, 12:34 PM
Hello Dee,

Custom data retrieval and saving logic can be implemented with a custom DataSource transport. The following documentation article provides information and examples:

http://docs.telerik.com/kendo-ui/framework/datasource/crud

Local transport and custom transport is practically the same thing, so follow the guidelines for local transport. The idea will be that remote requests will not be managed by the Kendo UI DataSource instances directly, but by custom logic, which interacts with the transport functions, and possibly, with the DataSource methods and events.

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource

Regards,
Dimo
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Data Source
Asked by
Bob
Top achievements
Rank 1
Answers by
Dimo
Telerik team
dee
Top achievements
Rank 1
Share this question
or