PDA

View Full Version : [FIXED] getNode return wrong record after add new record



traxanos
22 Sep 2011, 7:24 AM
REQUIRED INFORMATION

Ext version tested:

Ext 4.0.2

Browser versions tested against:

FF6
FF7

DOCTYPE tested against:

Strict
Transitional

Description:

If you add a new record to a store the grid view return wrong record
you must resort after add a new record

Steps to reproduce the problem:

click on add in toolbar
click on a cell of the new record

The result that was expected:

the getNode should deliver the new added record

The result that occurs instead:

the getNode deliver the record of the next row

Test Case:



Ext.create('Ext.data.Store', {
storeId:'sampleStore',
fields:['name', 'category'],
groupField: 'category',
data:{
items:[
{ name: 'Name 1', category: 'Group 1'},
{ name: 'Name 2', category: 'Group 2'},
{ name: 'Name 3', category: 'Group 1'},
{ name: 'Name 4', category: 'Group 2'},
{ name: 'Name 5', category: 'Group 1'},
{ name: 'Name 6', category: 'Group 2'},
{ name: 'Name 7', category: 'Group 1'},
{ name: 'Name 8', category: 'Group 3'},
{ name: 'Name 9', category: 'Group 1'},
{ name: 'Name 10', category: 'Group 2'},
{ name: 'Name 11', category: 'Group 1'},
{ name: 'Name 12', category: 'Group 4'},
{ name: 'Name 13', category: 'Group 1'}
]
},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});

var groupingFeature = Ext.create('Ext.grid.feature.Grouping', {})


var selModel = Ext.create('Ext.selection.CellModel', {
listeners: {
scope: this,
select: function(cm, record, row, column) {
console.log(record.get('name'));
}
},
preventWrap: true
})

Ext.onReady(function() {


var test2 = Ext.create('Ext.grid.Panel', {
frame: true,
features: [groupingFeature],
title: 'Test2',
renderTo: 'test2',
selModel: selModel,
style: 'margin: 10px auto;',
store: Ext.data.StoreManager.lookup('sampleStore'),
tbar: [
{
text: 'Add',
scope: test2,
handler: function() {
Ext.data.StoreManager.lookup('sampleStore').add({
name: "Wrong Record",
category: 'Group 1'
});

}
},
{
text: 'Workaround after add',
scope: test2,
handler: function() {
Ext.data.StoreManager.lookup('sampleStore').sort(Ext.data.StoreManager.lookup('sampleStore').sorters);
}
}
],
columns: [
{
header: 'Name',
dataIndex: 'name'
},
{
header: 'Category',
dataIndex: 'category'
}
],
width: 1000
});
});



http://www.youtube.com/watch?v=uc38ArrUVaA

traxanos
5 Oct 2011, 2:33 AM
where i can find the fix? i have test it with 4.0.6 and i have a support access for svn, but i can't find an update for this fix.

evant
5 Oct 2011, 2:37 AM
The fix will be part of 4.1, there's a new config option sortOnAdd that has been added to the store.

Animal
17 Nov 2011, 10:37 AM
Actually I'm removing sortOnAdd

The store knows when it is sorted.

It has a collection of sorters created from the configuration of the Store, groupField and sorters configs.

So I'm fixing the Store to always add in the correct sort order if sorted.