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

Link between DataSource objects

5 Answers 112 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Dr.YSG
Top achievements
Rank 2
Dr.YSG asked on 14 Jun 2013, 04:29 PM
I have a Grid, with a KendoDataSource that provides the data. That grid has some aggregate data. The entire data sits in a KendoObservableObject  in my VM.

01.vm.SetLayers = function (values) {
02.    //this.LayerTable.data(values);
03.    //this.LayerTable.aggregate = [{ field: "FileCount", aggregate: "count" }];
04.    //this.trigger("change", { field: "LayerTable" });
05.    this.LayerTable = new kendo.data.DataSource({
06.        data: values,
07.        aggregate: [
08.            { field: "FileCount", aggregate: "count" },
09.            { field: "Size", aggregate: "sum" }
10.        ]
11.    });
12.    this.trigger("change", { field: "LayerTable" });
13.};

I have another calculated field in the VM which shows the sum and count:

01.var totalFiles = function () {
02.    return this.LayerTable.aggregates().FileCount.count;
03.};
04.var totalSize = function () {
05.    return this.LayerTable.aggregates().Size.sum;
06.};
07.vm = kendo.observable({
08.    InfoTable: infoTable,
09.    LayerTable: layerTable,
10.    StatsTable: statsTable,
11.    TotalFiles: totalFiles,
12.    TotalSize: totalSize
13.});
I would like have the TotalFiles and TotalSize as column values in another Grid (which is backed by a different VM DataSource. Is this sort of chaining possible?

01.var infoTable = [
02.    { Item: "Status", Value: "Initializing" },
03.    { Item: "XHR2", Value: false },
04.    { Item: "B64", Value: false },
05.    { Item: "PouchDB", value: "" },
06.    { Item: "Center", Value: "xx" },
07.    { Item: "Date", Value: "xx" },
08.    { Item: "Zoom", Value: 0 },
09.    { Item: "Total Files", Value: 0 },
10.    { Item: "Total Size", Value: 0 }
11. 
12.];

5 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 18 Jun 2013, 03:21 PM
Hi Dr.YSG,

If I understood correctly, your aim is to bind the elements of one Grid to values from two different View-Models. I am afraid that this is not supported - s given container (html element) can have only one binding target.

As a possible workaround I suggest to reference the ViewModel field like a JavaScript function/variable through the footerTemplate.

I hope the information will help. In case I misunderstood your case, please provide a small but runnable sample that illustrates your case. In this way I would be able to get a better understanding of your exact scenario and assist you further.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dr.YSG
Top achievements
Rank 2
answered on 18 Jun 2013, 03:31 PM
Not exactly. Only one VM, but two separate DataSources within that VM.
0
Accepted
Alexander Valchev
Telerik team
answered on 20 Jun 2013, 11:30 AM
Hello Dr.YSG,

The functionality is not supported - it is possible to combine information from two DataSource instances in the footerTemplate. The only solution which I can suggest is to reference the field which you would like to display manually like a JavaScript variable.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dr.YSG
Top achievements
Rank 2
answered on 20 Jun 2013, 02:59 PM
Good to know. Thank you Alex.

Maybe you will consider this sort of DataSource chaining in the future. It would be nice to set up declarative chains of raw data, that is then processed to give filtered, aggregated, and other statistics, and then injected into other data sources for further processing.

One can imaging an entire data-flow chain of processing, where each node does some processing.

0
Alexander Valchev
Telerik team
answered on 24 Jun 2013, 11:56 AM
Hi Dr.YSG,

Thank you for the feedback. I will forward your suggestion to the team for further discussions.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Dr.YSG
Top achievements
Rank 2
Answers by
Alexander Valchev
Telerik team
Dr.YSG
Top achievements
Rank 2
Share this question
or