Answered by:
createGrouped bug?

Question
-
Hi all,
I am doing an app with a datasource created from an array. I picked some bits here and there to make this work.
var groupDataSource = AppData.groupedItemsSubset().createGrouped(this.groupKeySelector, this.groupDataSelector, this.groupSorter).groups;
ui.setOptions(listView, {
itemDataSource: AppData.groupedItemsSubset().dataSource,
itemTemplate: itemTemplate,
groupDataSource: groupDataSource.dataSource,
layout: new ui.GridLayout({ groupHeaderPosition: "top" })
});The problem is, when I specify the groupSorter parameter (3rd in createGrouped), my items are not only unsorted, but some of my groups are mixed up and the group headers are missing.
Any ideas? The docs seem to support this :
http://msdn.microsoft.com/en-us/library/windows/apps/hh700742.aspx
Monday, March 12, 2012 6:58 PM
Answers
-
Hi Pedro,
I think the problem is the sorting is only happening in the Binding.List instance you created for groupDataSource. Perhaps try refactoring your code slightly:
var data = AppData.groupedItemsSubset.groupDataSource.createGrouped(this.groupKeySelector, this.groupDataSelector, this.groupSorter); ui.setOptions(listView, { itemDataSource: data.dataSource, itemTemplate: itemTemplate, groupDataSource: data.groups.dataSource, layout: new ui.GridLayout({ groupHeaderPosition: "top" }) });
Cheers,
-Jeff
- Edited by Jeff Fisher [MSFT]Microsoft employee Monday, March 12, 2012 10:50 PM
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Tuesday, March 13, 2012 2:50 PM
- Marked as answer by Jesse JiangModerator Monday, April 9, 2012 5:58 AM
Monday, March 12, 2012 10:49 PM
All replies
-
Hi Pedro,
I think the problem is the sorting is only happening in the Binding.List instance you created for groupDataSource. Perhaps try refactoring your code slightly:
var data = AppData.groupedItemsSubset.groupDataSource.createGrouped(this.groupKeySelector, this.groupDataSelector, this.groupSorter); ui.setOptions(listView, { itemDataSource: data.dataSource, itemTemplate: itemTemplate, groupDataSource: data.groups.dataSource, layout: new ui.GridLayout({ groupHeaderPosition: "top" }) });
Cheers,
-Jeff
- Edited by Jeff Fisher [MSFT]Microsoft employee Monday, March 12, 2012 10:50 PM
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Tuesday, March 13, 2012 2:50 PM
- Marked as answer by Jesse JiangModerator Monday, April 9, 2012 5:58 AM
Monday, March 12, 2012 10:49 PM -
Thank you. I did have a bug elsewhere. My subset was already a grouped dataset and it was confusing things.
Still, your post was useful. Thanks.
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Tuesday, March 13, 2012 2:50 PM
Tuesday, March 13, 2012 12:28 PM