Link between DataSource objects

6 posts, 1 answers
  1. Dr.YSG
    Dr.YSG avatar
    210 posts
    Member since:
    Dec 2009

    Posted 14 Jun 2013 Link to this post

    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.];
  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 18 Jun 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Dr.YSG
    Dr.YSG avatar
    210 posts
    Member since:
    Dec 2009

    Posted 18 Jun 2013 Link to this post

    Not exactly. Only one VM, but two separate DataSources within that VM.
  5. Answer
    Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 20 Jun 2013 Link to this post

    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!
  6. Dr.YSG
    Dr.YSG avatar
    210 posts
    Member since:
    Dec 2009

    Posted 20 Jun 2013 Link to this post

    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.

  7. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 24 Jun 2013 Link to this post

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