PDA

View Full Version : [CLOSED] DataView does not update the displayed rows correctly



simeon
6 Nov 2011, 2:32 PM
I have a list panel.
When I load the store it displays properly
when I call load on the store a second time with a search constraint it returns less records.

The doRefresh method has a bug in it that results in the displayed results being the html from the previous list.




doRefresh: function(me) {

var store = me.getStore(),
records = store.getRange(),
items = me.getViewItems(),
recordsLn = records.length,
itemsLn = items.length,
deltaLn = recordsLn - itemsLn,
i, item;

// No items, hide all the items from the collection.
if (recordsLn < 1) {
me.onStoreClear();
return;
}

// Too many items, hide the unused ones
if (deltaLn < 0) {
this.moveItemsToCache(itemsLn + deltaLn, itemsLn - 1);
//return;
// Have to comment out the return here or you will never be able to update the ui with a data set smaller then the previous data set.
}
// Not enough items, create new ones
else if (deltaLn > 0) {
this.doCreateItems(store.getRange(itemsLn), itemsLn);
}

// Update Data and insert the new html for existing items


// itemsLn has a length that matches the previous load data set and needs to be items.length
// This is the old verison -> for (i = 0; i < itemsLn; i++) {

// this one works correctly
for(i=0;i<items.length;i++)
{
item = items[i];
me.updateListItem(records[i], item);
}
},

simeon
6 Nov 2011, 6:27 PM
I finally figured out how to do the overrides correctly when using the auto loader.

here is my override for this bug.



Ext.define('DataView_OverRide', {
override:'Ext.dataview.DataView',
doRefresh: function(me) {

var store = me.getStore(),
records = store.getRange(),
items = me.getViewItems(),
recordsLn = records.length,
itemsLn = items.length,
deltaLn = recordsLn - itemsLn,
i, item;

// No items, hide all the items from the collection.
if (recordsLn < 1) {
me.onStoreClear();
return;
}

// Too many items, hide the unused ones
if (deltaLn < 0) {
this.moveItemsToCache(itemsLn + deltaLn, itemsLn - 1);
}
// Not enough items, create new ones
else if (deltaLn > 0) {
this.doCreateItems(store.getRange(itemsLn), itemsLn);
}

// Update Data and insert the new html for existing items

for(i=0;i<items.length;i++)
{
item = items[i];
me.updateListItem(records[i], item);
}
}
})

Jamie Avins
7 Nov 2011, 8:37 AM
I noticed this as well and it has already been fixed for the next release. Thank you for the report.