PDA

View Full Version : [FIXED-1015] store.loadData( myData, true) causes render bug if records are replaced



RoyW
1 Jun 2010, 7:13 AM
Ext version tested:


Ext 3.2.1



Adapter used:


ext



css used:


only default ext-all.css





Browser versions tested against:


____
IE8
FF3.5.9 (firebug 1.5.4 installed)
Safari 4.0.3
Google Chrome 5.0.375.55



Operating System:


________
WinXP Pro



Description:


I am trying to update data records in a store. If I use loadData(myData, true)
and myData is a single new record then everything works. However if myData is a replacement record (has the same id as a record already in the store) then an error is encountered when the grid tries to re-render the data.



Test Case:



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Stateful Array Grid Example</title>

<!-- ** CSS ** -->
<!-- base library -->
<link rel="stylesheet" type="text/css" href="http://www.extjs.com/deploy/dev/resources/css/ext-all.css" />


<style type=text/css>
/* style rows on mouseover */
.x-grid3-row-over .x-grid3-cell-inner {
font-weight: bold;
}
</style>

<!-- ** Javascript ** -->
<!-- ExtJS library: base/adapter -->
<script type="text/javascript" src="http://www.extjs.com/deploy/dev/adapter/ext/ext-base.js"></script>

<!-- ExtJS library: all widgets -->
<script type="text/javascript" src="http://www.extjs.com/deploy/dev/ext-all-debug.js"></script>
<script type="text/javascript">
/*!
* Ext JS Library 3.2.1
* Copyright(c) 2006-2010 Ext JS, Inc.
* licensing@extjs.com
* http://www.extjs.com/license
*/
Ext.onReady(function(){

// sample static data for the store
var myData = [
{
'id' : 1001,
'company' : 'Alcoa Inc',
'price' : 29.01,
'change' : 0.42,
'pctChange': 1.47,
'lastChange' : '9/1 12:00am'
},
{
'id' : 1002,
'company' : 'Altria Group Inc',
'price' : 83.81,
'change' : 0.28,
'pctChange': 0.34,
'lastChange' : '9/1 12:00am'
},
{
'id' : 1003,
'company' : 'Wal-Mart Stores, Inc.',
'price' : 45.45,
'change' : 0.73,
'pctChange': 1.63,
'lastChange' : '9/1 12:00am'
}
];

var newRecord = {
'id' : 1004,
'company' : 'Verizon Communications',
'price' : 35.57,
'change' : 0.39,
'pctChange': 1.11,
'lastChange' : '9/1 12:00am'
};

var updateRecord = {
'id' : 1001,
'company' : 'Alcoa Inc',
'price' : 29.04,
'change' : 0.45,
'pctChange': 1.50,
'lastChange' : '9/1 12:20am'
};

// create the data store
var store = new Ext.data.Store({
reader : new Ext.data.JsonReader({
idProperty : 'id',
fields: [
{name : 'id'},
{name: 'company'},
{name: 'price', type: 'float'},
{name: 'change', type: 'float'},
{name: 'pctChange', type: 'float'},
{name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
]
})
});
// manually load local data
store.loadData(myData);

// create the Grid
var grid = new Ext.grid.GridPanel({
store: store,
columns: [
{id:'company',header: 'Company', width: 160, sortable: true, dataIndex: 'company'},
{header: 'Price', width: 75, sortable: true, renderer: 'usMoney', dataIndex: 'price'},
{header: 'Change', width: 75, sortable: true, dataIndex: 'change'},
{header: '% Change', width: 75, sortable: true, dataIndex: 'pctChange'},
{header: 'Last Updated', width: 85, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
],
stripeRows: true,
autoExpandColumn: 'company',
height: 350,
width: 600,
title: 'Grid Bug',
bbar : [
{
text : "Add new record",
handler : function(){
store.loadData(newRecord, true);
}
},
{
text : "Update record",
handler : function(){
store.loadData(updateRecord, true);
}
}
]
});

// render the grid to the specified div in the page
grid.render('grid-example');
});
</script>


</head>
<body>

<div id="grid-example"></div>
</body>
</html>

See this URL : http://www.jsfx.com/extjs/gridbug/index.html (http://www.jsfx.com/extjs/gridbug/index.html)


Steps to reproduce the problem:


Run the above example
Click on the "Add new record" button - works OK
Click on the "Update record" button - error occurs and the grid does not re-render



The result that was expected:


The first record in the grid should be updated



The result that occurs instead:


No update



Debugging already done:


Debugged into loadData() - the record gets inserted (replaced the old record)
the bug occurs in doRender of the grid
It is trying to render startRow=3, endRow=3 and is being passed an array of 2 records, the first
record in the array is



[U]Possible fix:


not provided

evant
8 Jun 2010, 11:00 PM
A fix for this has been added to SVN.

Mjollnir26
18 Jun 2010, 4:30 AM
Can't seem to locate it in the Commit-Log and don't have the Time to search all divs since 3.2.1 and SVN.
Got a little hint for me?

ivaylo.bakalov
21 Jun 2010, 6:35 AM
The SVN repository seems to be stuck in time. The date of the last check-in is June 6th.

t.oberthanner
19 Jul 2010, 11:30 AM
hi,

where do i find the bug fix? pleeease ;-)

thank you

ivaylo.bakalov
19 Jul 2010, 11:34 AM
I think it is revision: 6713, path: /branches/ext-3.3.x/src/data/Store.js

t.oberthanner
19 Jul 2010, 11:41 AM
I think it is revision: 6713, path: /branches/ext-3.3.x/src/data/Store.js
thank you very much for this fast response, but i am not allowed to access
https://svn.extjs.com/svn/ext/
is there any other way to get this bugfix?

ivaylo.bakalov
19 Jul 2010, 11:47 AM
You would have to buy Support Subscription or wait for 3.3 relase.

t.oberthanner
19 Jul 2010, 11:48 AM
Thank you for this information!

RoyW
10 Aug 2010, 9:00 AM
I have downloaded ext-3.3-beta1-6976 and run the test again. I do not get any errors, the record is inserted into the store but the grid does not render the new value.