PDA

View Full Version : Refreshing a list's view



danvega
21 Jul 2010, 2:44 PM
So I have a list and there are 4 buttons at the top of the screen Wed,Thurs,Fri,Sat. When you click one loadData method is called (below) which basically updates the list store with new data.

I found a small bug with my application and I am not quite sure how to fix it. Say on Wed you scroll half way down a long list and then click Fri. The list is still in the same position, in other words it did not go back to the beginning. I understand why as well, we are updating the data not the UI Component. Is there a way to refresh the view and have it start at the 1st data item?

I tried the method refresh() on the list but that did not work



loadData: function(b,e){
Ext.getBody().mask(false, '<div class="loading">Loading&hellip;</div>');
var dURL = 'data/' + b.id + '.txt';

Ext.Ajax.request({
url: dURL,//replace with AJAX call
success: function(response, opts) {
Ext.getBody().unmask();
result = JSON.parse(response.responseText);
var item = result;
if (item) {
Ext.getCmp('sessionList').getStore().loadData(item);
}
else {
//alert('There was an error retrieving the list.');
}
},
failure: function(response, opts){
Ext.getBody().unmask();
}
});
}

Sh1n1
22 Jul 2010, 4:24 AM
Maybe this will do:

yourList.scroller.scrollTo({x: 0, y: 0}, true); // scroll to the top

At least, it works fine for me in a similar situation.

danvega
22 Jul 2010, 4:55 AM
That works but it introduced a new bug. The load data method is called any time data needs to be loaded, this includes when the application loads. For whatever reason calling scroll to is causing my bottom toolbar to disappear