PDA

View Full Version : Update records of Ext.data.store an refresh List



b0hne
1 Sep 2011, 2:17 PM
Hi,

this is what i got:

Ext.regModel('Filiale', {
fields: ['id', 'name', 'address', 'distance', 'lat', 'lng'],

});


var ListStore = new Ext.data.Store({
model: 'Filiale',
id: 'ListStore',
autoLoad: false,
proxy: {
type: 'ajax',
url : '...',
reader: {
type: 'json'
}
}
});

var listPanel = new Ext.List({
title: 'List',
id: 'addresslist',
store: ListStore,
itemTpl: '<div class="contact">{name}, {address}, {distance}</div>',

});



What i am trying to do is to receive the data via ajax. Then after the store has completely loaded i want to change the received records and afterwards refresh the list to display the new data.

So my question is: How can i change the store-data and force the list to be refreshed with the changed data. I've tried my luck with

//on store-load: change the records:

ListStore.load(function(){// change the records here});

//then bind the "new" store to the list:

listPanel.bindStore('ListStore');

But the displayed data always remains as it was initially received via the ajax-request.

Anyone got an idea ?

b0hne
3 Sep 2011, 2:48 PM
It seems to be a problem with the timing.
When the list gets rendered, the store-data is not finished loading/changing.

I've tried to call the ListStore.load() when list's "beforerender" event is fired, but the displayed data is still the old one...