PDA

View Full Version : Unable to refresh grid w/ getDataSource().reload()



RealSalmon
13 Feb 2008, 8:08 AM
I have a grid whose data source I would like to refresh with new parameters. I'm able to accomplish this by creating a completely new data source and calling grid.reconfigure(), however that seems like overkill when all I really need to do is specify a different set of params for the data source reload() call.

The problem that I'm having is that even after calling the data source's reload() method, the original results are being used.

I have verified the that the HTTP request returns the expected results.

Ext 1.1

The code:



show_files: function(data_point_id) {

var ds = new Ext.data.JsonStore({
url: '/xmms/index/files/',
totalProperty: 'results',
root: 'rows',
id: 'id',
fields: [
{name: 'id'},
{name: 'name'},
{name: 'title'},
{name: 'types'},
{name: 'description'},
{name: 'ids'}
]
});

var cm = new Ext.grid.ColumnModel([
{id: 'title', header: "Title", dataIndex: 'title'},
{id: 'formats', header: 'Formats', dataIndex: 'types', renderer: DialogProto.render_formats}
]);

var grid = new Ext.grid.Grid('grid', {
ds: ds,
cm: cm,
autoExpandColumn: 'title',
enableColumnHide: false,
enableColumnMove: false,
loadMask: true

});

ds.load({params: {id: data_point_id},
callback: function() {
var layout = DialogProto.dialog.getLayout();
layout.beginUpdate();
layout.add('center', new Ext.GridPanel(grid));
layout.endUpdate();
grid.render();
}});

// The above works fine and renders the grid as expected
// Attempting to refresh the grid (simulated below) data source fails
//
// The refresh occurs, but the newly reloaded dataset is ignored -- the original is used
alert('Attempting refresh . . . ');
grid.getDataSource().reload({params: {id: 5},
callback: function() {
grid.getView().refresh();
alert(this.getTotalCount()); }
});
}


Thanks for any help.

fay
13 Feb 2008, 8:38 AM
Your code looks okay, would your server be caching the file? Try:


ds.reload({params: {id: 5}, method:'POST'});

Or:


ds.proxy.conn.url = '/xmms/index/files/?r=' + Math.random();
ds.reload({params: {id: 5}, method:'POST'});

RealSalmon
13 Feb 2008, 9:22 AM
Your code looks okay, would your server be caching the file?

I'd hoped that was the case, but according to FireBug the request and response are exactly what I expect.

For now I've fallen back to just creating a fresh data source every time, which works fine. It just seems a little sloppy.

dearsina
13 Aug 2008, 7:25 AM
i have a similar problem. firebug says variables are being sent via post, but PHP doesn't seem to receive them (print_r($_request); results in nothing useful). my php knowledge is stronger than ext, so i'm inclined to think something is up with my ext code (working on a grid), but surprised that firebug reports something that doesn't seem to hold true.