PDA

View Full Version : grid sorted with grouping shows WRONG selection



Webtel
9 Dec 2011, 4:23 AM
i have a grid with grouping feature. i also use there 'rownumberer' column. ...

L.p. is messed up after groups are gethered (it is always grouped, rows come unsorted). i.e. "lp 2" is on the bottom below 3 and 4. (because it is in second group)

Most important problem is that selection is also wrong. (when i click on row X selection shows that Y is selected).

Only first row is not affected (second belongs into second group, but third is in first group).

SO - grouping feture ruins my form binding. What can be done about this?

skirtle
9 Dec 2011, 5:16 AM
What is 'lp'?

Are you able to provide a small, reproducible test case for your problem?

Webtel
9 Dec 2011, 6:55 AM
Lp.== list position (rownumberer label)

test case :
1. - make a grid with grouping,
2. add rownumberer column,
3. make sure server data (rows) come unsorted (see below)
4. TADA. (click on a row and then see what shows selection model; beside Lp behaviour);

server data:

rows:[{name:'a',group:2,id:1},{name:'b',group:1,id:2},{name:'c',group:2,id:3},{name:'d',group:1,id:4}]

grouping feature:

Ext.create('Ext.grid.feature.Grouping', {
enableNoGroups:false,enableGroupingMenu:false,
startCollapsed: false});


store cfg :

groupField:'group',
sorters:['name'],

... efect is as i stated - "L.p." is in wrong order and selection is also messed up (THIS IS THE PROBLEM).

Webtel
11 Dec 2011, 7:07 AM
Ext.create('Ext.Window',{
autoShow:true,
width:700,
autoDestroy:true,
height:500,
layout:'fit',
items:[{
xtype:'gridpanel',
store:Ext.create('Ext.data.Store',{
data:[{name:'a',group:2,id:1},{name:'b',group:1,id:2},{name:'c',group:2,id:3},{name:'d',group:1,id:4}],
remoteSort:true,groupField:'group',fields:['id','name','group']

}),
features:[Ext.create('Ext.grid.feature.Grouping', {})],
plugins:[Ext.create('Ext.grid.plugin.CellEditing', {})],
columns:[{dataIndex:'id',editor:{xtype:'textfield'}},{dataIndex:'name',editor:{xtype:'textfield'}},{dataIndex:'group',editor:{xtype:'textfield'}}]
}]
});

PS. The problem is settin remoteSort TRUE. JUst try to edit 2. or 3. row

David K.
10 Mar 2012, 11:34 AM
I have the exact same problem. It seems that the cell-editing plugin and the grouping feature don't work together quite well.

A possible solution is to let the data be sorted on the server-side.

I hope this problem gets fixed soon, as it is really an important feature for me!

abhaykulkarni16
29 Oct 2012, 2:03 AM
Is the thread alive?
Please help with this. I am stuck with this issue for too long now.

I have a grid with

Remote Paging
Remote Sorting
Remote Filtering
local grouping
There is a context menu defined on the grid. On menuitem click, I am trying to access the record selected because of the right click.

The model has an idPropery of the unique key, say ID.

The problem - When I right-click any row, the handler method gets called, has a param "model". It is the record right-clicked on. This record is wrong.

Lets say I have groups with IDs like these,
x -1, 2, 4 and 7
y -3, 5
z -6

If I right-click 1 or 2, the handler method has correct record. If I do it on 4, it gives the record with ID 3. On 7, it gives record with ID 4.

If this is done when grouping turned off through headers, it works just fine.

As David noted, data is being sorted on server side.
I have done lot of debugging, but couldn't find the root cause.
Thanks in advance for replies.

RSSoll
14 Feb 2013, 2:54 AM
Hi,
I have similar problem with grouping and changing field that records are grouped by. After the change, selection picks wrong items. To solve this problem after every change that may move record from group to group (and change order) I always run sort() on a store. It looks like a huge time consume (fortunately I have small amount of data) but at least records are in correct order.

dannyx
14 Apr 2013, 2:34 PM
Confirming same behaviour, editing the grouping column will move the row to
the new group and selection will consider the row being in the old position.
store.sort() solved it for the moment (ty ^^)

jamol91
19 Mar 2014, 10:26 PM
I was having the same issue and the following did the trick:
I added this sorters in my store:
sorters: [
{
property: 'category',
direction: 'ASC'
}
]
Note the 'category' is the column I used for grouping as groupField in my store.
Sorting with the groupField column is NEEDED, otherwise grid selection will work not properly.

maneljn
31 Mar 2014, 6:47 AM
How can i force a re-sort of the store by the grouped column, when an user groups from any column in a grid ?

Manel

jamol91
31 Mar 2014, 9:05 PM
There is a method sort in store, I hope it is what you need. Here docs (http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.Store-method-sort)