PDA

View Full Version : Don't Want Groups Sorted in GroupingStore



annRT
8 Sep 2009, 1:28 PM
Hi,

I have a GroupingStore. I am grouping on a numerical field. So, for instance, all my "10"s are grouped, all my "5"s, etc. Also, my groups are sorted so the "5" group is shown prior to the "10" group. I don't want this to happen. I want the groups to be shown in the order they are returned from the server. Anybody know of an easy way to do this?

Thanks in advance.

jnicora
8 Sep 2009, 2:24 PM
Are you setting the default sort in your store to the grouping field?



groupField: "grpFld",
sortInfo: {
field: "grpFld",
direction: "DESC"
}

annRT
8 Sep 2009, 2:35 PM
No...it's set to a different field...but the behavior is the same (sorting groups by groupfield) even if I remove it.

jnicora
8 Sep 2009, 2:36 PM
hmm, maybe post snippets for the store/grid/data?

annRT
8 Sep 2009, 3:05 PM
Here it is (generalized)...



var myStore = new Ext.data.GroupingStore({
url: myServlet,
reader: Ext.data.getJsonReader(),
sortInfo: {field: 'YNflag', direction: "DESC"},
groupField: 'the_ID'
});

var myGrid = new Ext.grid.GridPanel({
ds: myStore,
cm: myColumnModel,
autoScroll: true,
view: myView,
stripeRows: true,
trackMouseOver:false,
bbar: myPager,
sm: myCBSelectionModel,
flex: 1
});



Nothing special. Is this the default behavior of the GroupingStore? If so...any ideas on how to override it?

Thanks for the help, btw!

jnicora
8 Sep 2009, 3:15 PM
I need some more clarification, in your store config, you have specified YNflag as the field to sort, so you can't expect the grouping field (the_ID) to be sorted. If you make the_ID the field in sortInfo, then your grid should be both grouping AND sorting on that field. Does this happen? Is that what you are trying to do?

annRT
8 Sep 2009, 3:22 PM
I want the items grouped by the_ID. But within the the groups themselves I want them sorted by the YNFlag. Like this:

10 Y
10 N
10 N

5 Y
5 N
5 N

But my groups are sorted in asc order...so the 5 group is shown before the 10 group even though data is returned in reverse. This is probably the default behaviour I'm guessing?

jnicora
8 Sep 2009, 3:26 PM
OK, I think I follow you now. I think you are seeing default behavior, but it makes me wonder if your grouping field is somehow sorted as text and not as numbers? have you tried adding types to your store fields? ({name: "the_ID", type: "int"})

reaching here...

annRT
8 Sep 2009, 3:45 PM
Well...yes, the_id field doesn't have a specific type assigned to it, but thats ok I guess because I don't want it sorted on that field, just grouped. If I wanted it sorted on that field and the sort wasn't working then yeah....that would be a great thing to do. :s