PDA

View Full Version : Problem with group and sort



DerSalz
24 Nov 2010, 3:30 PM
Hi,

I have a grid with a grouping store, grid filter, search field and sorting on columns. I do the filter part and the sorting remotely on the server. This is the function which creates the data store for my grid.



App.Features.ProjectSelection.DataStore = function () {
var dataStore = new Ext.data.GroupingStore({
proxy: new Ext.data.HttpProxy({ url: 'Reporting/ProjectSelectionList' }),
reader: new Ext.data.JsonReader({
idProperty: 'ProjectID',
totalProperty: 'Total',
root: 'Projects',
fields: [
{ name: 'ProjectID', type: 'int' },
{ name: 'Category', type: 'string' },
{ name: 'ProjectNumber', type: 'string' },
{ name: 'ProjectDescription', type: 'string' },
{ name: 'ProjectComment', type: 'string' },
{ name: 'Division', type: 'int' }
]
}),
// without the initial sort info the grouping by category is not working correctly!
sortInfo: { field: 'Category', direction: "ASC" },
groupField: 'Category',
remoteSort: true,
autoLoad: true
});

return dataStore;
}


First I loaded the data without the sortInfo set. The result was that the groups appeared twice or three times in the grid. That doesn't happen with the local sort. I checked the JSON which has been returned from the server and that is correct. No duplicated rows or something like that. I searched the forum and found a thread where somebody mentioned to set the sortInfo initially. I did that and the first load was then correctly shown in the grid. But when I clicked on another colum to sort by that field the strange behaviour appeared again. The sort and dir fields were sent correctly to the server. The data returned was correct as well. The groups in the grid appeared a few times.

When clicking on some of the duplicated groups in the grid only one group really expanded. The other "phantoms" stayed collapsed. (Which seems to be obvious as the group was already expanded...)

I tried everything (also remoteGroup, setting the sortInfo again in beforeLoad etc.). Nothing helped. The strange thing is, that this only happens when no filter is set. If next to the sort a grid filter or the search field is set the display is correct!

As attachement you find a picture (grouping_initial_load.png) on the initial load with the sortInfo set. Everything is fine. The second picture shows how the grid looks like after sorting on one column (Project Description). The same count of records (400) but many duplicated groups. As this is a customer project I had to anonymous the grouping info.

I spent already a day on this... please help. What am I doing wrong?

Thanks in advance.

DerSalz
24 Nov 2010, 3:33 PM
I forgot to mention that I'm using the latest ExtJS 3.3.0.

DerSalz
25 Nov 2010, 3:11 AM
I'm still not able to solve the problem.

I tried to limit the data on two categories (groups) with 1 record in first group and two records in the second. Then I expanded both groups. Everything looked fine (sortInfo not set, see attached picture grouping_1.jpg). Then I sorted on column "Project Description". The result is shown in the second picture (grouping_2.jgp). After the sort I have two identical groups ("Group B") with one record in each group. The expand/collapse functionality acts as described in my previous post.

Am I really the only one with this problem?

Please help. I'm willing to spent more time on analyzing this issue but I would appreciate any help or hint.

Or can anybody at least confirm the remoteSort combined with grouping and without an initial sortInfo works for him? For me this is a big bug which should be confirmed by ExtJS!

Thanx

Condor
25 Nov 2010, 6:51 AM
Configure your store with both remoteSort:true and remoteGroup:true and have your server sort the result on 'groupField'/'groupDir' parameters first and on 'sort'/'dir' parameters after that.

DerSalz
25 Nov 2010, 9:54 AM
Hi Condor,

you are unbelievable! I'm more than impressed. You answered around 20 posts in 20 minutes. =D>

This solved my problem! Thanks a lot!

I thought I tried that already but I made a mistake with the sorting sequence on the server.

You have my full respect! Thanks again.

Salz