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

Add grouping or aggregates to Grid initialised from table

2 Answers 348 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 31 Jul 2012, 12:54 PM
Hi, I am initializing a kendo grid from a table that already has a header, and tbody with rows and columns,
I am not sure how to add grouping/aggregates to this table, or can this only be done when using a datastouce??

I want to add a grouping on the DATE column, with an aggregate sum on the CHARGE column,

can you please help

$(document).ready(function () {
        $("#Journeys").kendoGrid({
            scrollable: false,
            pageable: true,
            sortable: {
                mode: "single",
                allowUnsort: false
            },
            filterable: true
        });
 
    });


<table id="Journeys">
    <colgroup>
        <col style="width: 28px;" />
        <col style="width: 180px;" />
        <col style="width: 210px;" />
        <col style="width: 150px;" />
        <col style="width: 130px;" />
    </colgroup>
    <thead>
        <tr>
            <th data-field="rank"></th>
            <th data-field="Date">Date/Time</th>
            <th data-field="Journey">Journey/Action</th>
            <th data-field="Charge">Charge</th>
            <th data-field="Action"></th>
        </tr>
    </thead>
    <tbody>
        @foreach (var model in Model)
        {
            <tr>
                <td></td>
                <td>@Html.Encode(model.Date)</td>
                <td>@Html.Encode(model.JourneyDescription)</td>
                <td>@Html.Raw(model.FormattedCharge)</td>
                <td></td>
            </tr>
        }
    </tbody>
</table>

2 Answers, 1 is accepted

Sort by
0
Kris
Top achievements
Rank 1
answered on 14 Oct 2014, 07:15 AM
Hi Simon,

Were you able to find a solution to this problem because am have the same thing and I want to avoid convert the exiting Grid table structure into div?

Thanks!
0
Kiril Nikolov
Telerik team
answered on 17 Oct 2014, 07:37 AM
Hello Kris,

You can still use the aggregates method of the dataSource if you want to get information about some aggregated value. And you can also define the grouping inside, please see the example that I created:

http://dojo.telerik.com/ERAhe/2

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Simon
Top achievements
Rank 1
Answers by
Kris
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Share this question
or