View Full Version : [FIXED] [] Inserting records into store at index 0 always seems to append instead

4 Apr 2013, 12:20 PM

Ext version tested:

Ext 4.2.0 rev 663

Browser versions tested against:

FF20 (firebug 1.11.2 installed)


Insert(index,records) function in Ext.data.Store incorrectly appends record to end of snapshot array even though you may manually insert a record at the beginning. This causes items in a ComboBox to display out of order.

Steps to reproduce the problem:

Create a Ext.data.Store that loads data via proxy or manually pre-populated as in the attached test case.
Assign the store to a ComboBox.
After the ComboBox has been rendered, but nothing has been chosen from the picker, manually insert a record into the store at a position other than at the end (insert it at the beginning for example).

The result that was expected:

The item should show up in the ComboBox at correct position

The result that occurs instead:

The item is always appended to the end of ComboBox

Test Case:

Ext.define('MyDataModel', {
extend: 'Ext.data.Model',
fields: ['text', 'value']

var store = new Ext.data.Store({
fields: ['text', 'value']

{text: 'Item 1', value: 'Value 1'},
{text: 'Item 2', value: 'Value 2'},
{text: 'Item 3', value: 'Value 3'}

new Ext.window.Window({
items: [
xtype: 'combobox',
fieldLabel: 'Test',
store: store,
displayField: 'text',
valueField: 'value',
queryMode: 'local'
],listeners: {
render: function(){
//this should insert the record in position 0 in the combo, bit always shows up at the end.
text: 'Item 0',
value: 'Value 0'


Debugging already done:

ComboBox initComponent() function calls Ext.data.Store filter() function.
Ext.data.Store filter() function establishes store snapshot object.
Ext.data.Store insert(index,records) function inserts record into the correct position in the data array object, but always appends record to snapshot data array object, so this causes these two objects to be out of sync index wise.
The ComboBox picker appears to derive its list from the snapshot object which is out of sync.

Possible fix:

The insert(index,records) function in Ext.data.Store could be modified in the following manner:

me.data.insert(index, out);

if (me.snapshot) {
//me.snapshot.addAll(out); //this is the problem
me.snapshot.insert(index,out); //this seems to solve the problem.

4 Apr 2013, 12:26 PM
I can confirm this is .663, however after testing with the latest from source build this issue has already been resolved. Thanks for the test case.