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.
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.