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

SQL Style Group By in a Data Source

3 Answers 148 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 2
Shawn asked on 05 Nov 2013, 02:42 AM
We are trying to basically and literally group data in a data source like you can do with SQL when selecting against a table.

So I get data that looks like the following:

var grid = $("#grid").kendoGrid({
    dataSource: {
        data: [
            {f1: "1", f2:"2", f3:"3", f4:"4", f5:"5", f6: "1"},
            {f1: "1", f2:"2", f3:"3", f4:"4", f5:"5", f6: "3"},
            {f1: "1", f2:"2", f3:"3", f4:"6", f5:"7", f6: "2"},
            {f1: "1", f2:"2", f3:"3", f4:"6", f5:"7", f6: "1"},
            {f1: "1", f2:"2", f3:"3", f4:"6", f5:"5", f6: "2"}
        ]},
}).data("kendoGrid");

We want to group by f1, f2, f3, f4 and sum on f6.

The result when we show this data in a grid or list view should be that the data source has only 2 rows in it

            {f1: "1", f2:"2", f3:"3", f4:"4", sum: "4"},
            {f1: "1", f2:"2", f3:"3", f4:"6", sum: "5"},

We do not want group header and so forth, just to literally group the data.

How can I accomplish this?

3 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 06 Nov 2013, 08:08 AM
Hi Shawn,

I would suggest you to take a look at the following demo showing grouping and aggregates inside the Kendo UI Grid:

http://demos.kendoui.com/web/grid/aggregates.html

After grouping the dataSource will still contain the same data and structure as before, but the view (the data displayed in the widget) is changed. I am telling you this because you said that you want to change the structure of the dataSource and its fields.
 
Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Shawn
Top achievements
Rank 2
answered on 06 Nov 2013, 08:14 AM
We already looked at this example and it actually does not help us in solving the posed problem.

We are actually binding to a list view so do not have the luxury of taking advantage of a grid.

Right now our only course of action is to do what we need to do outside of the data source but this seems like something that the data source should handle easily.

If I am wrong can you show us how to do it in the example I provided to create the view of 2 rows as shown below.
0
Kiril Nikolov
Telerik team
answered on 06 Nov 2013, 03:09 PM
Hi Shawn,

As you have given an example with the Kendo UI Grid in your first example, I thought that you are using this widget in your project. Unfortunately this is not supported with the ListView and you will need to handle those data operations outside of the dataSource.
 
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
Data Source
Asked by
Shawn
Top achievements
Rank 2
Answers by
Kiril Nikolov
Telerik team
Shawn
Top achievements
Rank 2
Share this question
or