add aggregate to DataSource (after populating with data)

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

    Posted 14 Jun 2013 Link to this post

    I have a VM has a DataSource in it.

    var layerTable = new kendo.data.DataSource();
    When new data arrives, I am able to populate the LayerTable with the data() function. But I also want to dynamically add in aggragates to this.

    1.vm.SetLayers = function(values) {
    2.    this.LayerTable.data(values);
    3.    this.LayerTable.aggregate = [{ field: "FileCount", aggregate: "count" }];
    4.    //this.trigger("change", { field: "LayerTable" });
    5.};
    I am finding that when I later try to get the aggregates() I get an empty object.

    1.vm.LayerTable.aggregates();

  2. Answer
    Daniel
    Admin
    Daniel avatar
    2118 posts

    Posted 18 Jun 2013 Link to this post

    Hi,

    You should use the aggregate method.

    Regards,
    Daniel
    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. Answer
    Dr.YSG
    Dr.YSG avatar
    210 posts
    Member since:
    Dec 2009

    Posted 18 Jun 2013 Link to this post

    Yes, that is a typo on my part.

    I am now able to do what I thought was not possible.

    1. Setup (at init time) the DataSource, with aggregates() but with no data
    2. Receive JSON via XHR
    3. do a DataSource.data() and supply the new data, and behold, the aggregates() values are filled in.

Back to Top