dragonfly
13 Jul 2007, 1:31 PM
I paste the code below:
Ext.onReady(function(){
// create the Data Store
var ds = new Ext.data.Store({
proxy: new Ext.data.ScriptTagProxy({
url: '/test/FetchData.do'
}),
reader: new Ext.data.JsonReader({
root: 'records',
totalProperty: 'recordCount',
id: 'emplId'
}, [
{name: 'emplId'},
{name: 'name'}
]),
remoteSort: true
});
ds.setDefaultSort('emplId', 'asc');
var cm = new Ext.grid.ColumnModel([{
header: "Emp#",
dataIndex: 'emplId'
},{
header: "Name",
dataIndex: 'name'
}]);
cm.defaultSortable = true;
// create the editor grid
var grid = new Ext.grid.Grid('test-grid', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
enableColLock:true,
loadMask: true
});
// render it
grid.render();
var gridFoot = grid.getView().getFooterPanel(true);
// add a paging toolbar to the grid's footer
var paging = new Ext.PagingToolbar(gridFoot, ds, {
pageSize: 1,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
});
// trigger the data store load
ds.load({params:{start:0, limit:1}});
});
Request submitted: (got from firebug)
/test/FetchData.do?start=0&limit=1&sort=emplId&dir=ASC&_dc=1184361257058&callback=stcCallback1001
JSON data returned: (got from firebug)
stcCallback1001([{"records":[{"emplId":"1","name":"Steven Irwin"}],"recordCount":9736}]);
Anything wrong? It's so simple, but it doesn't work. Am I stupid or what?
Many thanks in advance!
Ext.onReady(function(){
// create the Data Store
var ds = new Ext.data.Store({
proxy: new Ext.data.ScriptTagProxy({
url: '/test/FetchData.do'
}),
reader: new Ext.data.JsonReader({
root: 'records',
totalProperty: 'recordCount',
id: 'emplId'
}, [
{name: 'emplId'},
{name: 'name'}
]),
remoteSort: true
});
ds.setDefaultSort('emplId', 'asc');
var cm = new Ext.grid.ColumnModel([{
header: "Emp#",
dataIndex: 'emplId'
},{
header: "Name",
dataIndex: 'name'
}]);
cm.defaultSortable = true;
// create the editor grid
var grid = new Ext.grid.Grid('test-grid', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
enableColLock:true,
loadMask: true
});
// render it
grid.render();
var gridFoot = grid.getView().getFooterPanel(true);
// add a paging toolbar to the grid's footer
var paging = new Ext.PagingToolbar(gridFoot, ds, {
pageSize: 1,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
});
// trigger the data store load
ds.load({params:{start:0, limit:1}});
});
Request submitted: (got from firebug)
/test/FetchData.do?start=0&limit=1&sort=emplId&dir=ASC&_dc=1184361257058&callback=stcCallback1001
JSON data returned: (got from firebug)
stcCallback1001([{"records":[{"emplId":"1","name":"Steven Irwin"}],"recordCount":9736}]);
Anything wrong? It's so simple, but it doesn't work. Am I stupid or what?
Many thanks in advance!