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

Datasource Group then sort

8 Answers 497 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael
Top achievements
Rank 1
Michael asked on 20 Dec 2012, 10:25 PM
Hello,

I have a data set similar to this:

Name:Joe Smith,  Rank:Captain, RankNum: 3
Name:Jane Doe,  Rank:Chief,     RankNum: 1
Name:Paul Smith,Rank:FF,         RankNum:4

I have a datasource that pulls into a MobileUI ListView.  What I am having an issue is that I am grouping the data based on Rank, but I want the ListView to be sorted by RankNum.  If I just apply the sort with no grouping the ListView displays sorted by RankNum, but if I add a group then I loose my sort.  Is there a way to solve this? 

8 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 24 Dec 2012, 01:21 PM
Hi Michael,

I am afraid that this is not currently supported. When you group your data it is being sorted by the field you are grouping by. 

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Sean
Top achievements
Rank 1
answered on 07 Aug 2013, 07:44 PM
Sorry to dig this one back up.

Has there been any plans or progress in allowing sorting by different columns other than the group?

Thanks,
Sean
0
Atanas Korchev
Telerik team
answered on 12 Aug 2013, 06:50 AM
Hello Sean,

 There isn't any progress with this regard. Sorting by the group field is currently used to properly apply paging. If we don't do that there we would need to re-implement the whole grouping and paging features with possible breaking changes.

 You can open a feature request for that in our feedback portal. This would help us track the interest in this feature.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Reuben
Top achievements
Rank 1
answered on 15 Aug 2013, 09:24 PM
Would it at least be possible to have the grouping not scramble the results returned by the server/datasource?  This happens in Chrome/Android.  iOS/Safari have no problem.

For example: http://jsfiddle.net/4K3V4/2/
Open it in Safari/iOS to see the expected behavior and Chrome/Android to see it get scrambled.

Expected behavior would be to group the items under fixed headers and since they are being returned from the datasource/server in the correct order LEAVE THEM THAT WAY.  Instead, Chrome/Android scramble the results and display them out of order.  Since this is not a consistent problem across all browsers I'm assuming that the problem is with the native javascript sort implementation - that said, Kendo UI could implement its own sort routine to eliminate this problem on all platforms.

0
Walid
Top achievements
Rank 1
answered on 27 Aug 2013, 11:40 AM
Can we find a workaround? I have a similar scenario.
For the example given in the first post, I was thinking we could group by RankNum + Rank, and then in the header template to show only the Rank.
So from a header template like this: "<span> ${value} </span>", to add some inline processing to remove the RankNumber. 

Another workaround that I was thinking would be to retrieve the data allready sorted, and after to insert 'fake' items. And for those faked items to show a different item template(fake the group header).  But this has limited functionality.

Looks feasible?


0
Sean
Top achievements
Rank 1
answered on 27 Aug 2013, 03:31 PM
Walid,

Here is the solution we ended up coming up with (it's a bit of a hack, but it works):

http://jsfiddle.net/xMmWy/

The data has a sort column that specifies the way we would like the data sorted.  We use this as the group specification.  Then when we create the grid, we do some column specifications to hide the "Grade" column and use it's data to override the "Sort" column using the template capability of columns.

Then in the databound function there is several things going on. In order for the group headers to display the proper data, we need to manipulate the DOM just a bit. Lines 39 - 42 are getting the data and finding the appropriate information to change and changing it.   Then we've also added the ability to click anywhere on the grouping rows to expand/contract the groups on lines 43-45.  And on additional operation we perform is to collapse all the groups by default on line 46.

Went through some pains to get this working in our environment, so I'm hopeful it can be of use to someone else. 

Thanks,
Sean

0
Walid
Top achievements
Rank 1
answered on 28 Aug 2013, 11:27 AM
Thanks for the reply Sean.
In the end I decided to group by a numeric column, so I can have the groups in the right order.
Also I modified the group header template to something like:

<script id="headerTemplate" type="text/x-kendo-template">
                 <span> #=GetGroupName(value)# </span>
</script>

Where "GetGroupName()" is a JS function that serches through an existing list of group names for the group with ID "value"
This works great for a kendo list, which is my scenario.

Cheers

0
Ralph
Top achievements
Rank 1
answered on 28 Sep 2013, 01:40 PM
Hi,

I also have this problem.
My problem is similar to what Reuben has stated (http://www.kendoui.com/forums/permalink/boHZJq6aG2OF1P8AAFTdxQ)

Would you please suggest a workaround to handle it?

Thanks!
Tags
Data Source
Asked by
Michael
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Sean
Top achievements
Rank 1
Reuben
Top achievements
Rank 1
Walid
Top achievements
Rank 1
Ralph
Top achievements
Rank 1
Share this question
or