Dynamic Grid Columns and Aggregate Function

4 posts, 0 answers
  1. Abdullah Önden
    Abdullah Önden avatar
    20 posts
    Member since:
    Aug 2009

    Posted 04 Feb 2010 Link to this post


    I have a Grid which generates its columns automatically. Grid's column counts changes with SQL. How can I add aggregate
    function to these dynamic columns? I'd like to show these in footer. Where should I control it, onitemdatabound or something?

  2. Tsvetoslav
    Tsvetoslav avatar
    1823 posts

    Posted 05 Feb 2010 Link to this post

    Hello Abdullah,

    Each auto-generated column causes the grid to trigger its ColumnCreated event where you can access the column (e.Column) and set its Aggregate function.

    I hope this helps.

    Best wishes,
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  3. DevCraft R3 2016 release webinar banner
  4. Marc Roussel
    Marc Roussel avatar
    429 posts
    Member since:
    Dec 2009

    Posted 15 Apr 2011 Link to this post


    Could you explain how I have this agregatefunction SumFunction in the Group Footer of the column which is a monetary column
    I should see something like $200 since I have 2 rows with the $100 each

    I tried this but there's nothing shown on the GROUP FOOTER

    void rgvTest_AutoGeneratingColumn(object sender, Telerik.Windows.Controls.GridViewAutoGeneratingColumnEventArgs e)
        if(e.Column.UniqueName == "Property2")
            e.Column.AggregateFunctions.Add(new SumFunction() { Caption = "", ResultFormatString = "C2" });
  5. Vipul
    Vipul avatar
    1 posts
    Member since:
    Mar 2016

    Posted 22 Mar Link to this post


    Here is the complete code for dyanmic grid with dynamic column and aggregate.

                    url: ",
                    datatype: "JSON",
                    type: "GET",
                    success: function (result) {
                        var items = $.parseJSON(result)[0];
                        var arrCol = [];
                        var arrAgg = [];
                        for (var index in items) 
    arrCol.push({ field: index, format: "{0:0}", aggregates: ["sum"], footerTemplate: "#= kendo.toString(sum, '0.00') #" });
    arrAgg.push({ field: index, aggregate: "sum" });
                        if (result.Result.length > 0) {
                            var dataSource = new kendo.data.DataSource({
                                data: $.parseJSON(result.Result),
                                group: { field: "Category" },
                                aggregate: arrAgg
                                dataSource: dataSource,
                                height: "auto",
                                scrollable: false,
                                sortable: true,
                                groupable: false,
                                columns: arrCol



Back to Top