PDA

View Full Version : Grid data is not being loaded from server(mvc)



mohin
29 Mar 2010, 2:30 AM
Hi, I am new at ExtJs and using ExtJs 3.1.1. I am trying to get Sliding pager grid working in my application. I am using exactly same as it is with the example and the only onething i want to do is to get the grid data from server. I am using new Ext.ux.data.PagingMemoryProxy. I have a controller named ExtGridController and it has an action "public JsonResult SlidingPagerData()" and it seems that the server is not being called. Is there anyone who can help me a bit?
Ext.onReady(function() {

// example of custom renderer function
function change(val) {
if (val > 0) {
return '<span style="color:green;">' + val + '</span>';
} else if (val < 0) {
return '<span style="color:red;">' + val + '</span>';
}
return val;
}

// example of custom renderer function
function pctChange(val) {
if (val > 0) {
return '<span style="color:green;">' + val + '%</span>';
} else if (val < 0) {
return '<span style="color:red;">' + val + '%</span>';
}
return val;
}

// create the data store
var store = new Ext.data.Store({
proxy: new Ext.ux.data.PagingMemoryProxy(new Ext.data.HttpProxy({ url: '/ExtGrid/SlidingPagerData' })),
remoteSort: true,
sortInfo: { field: 'price', direction: 'ASC' },
reader: new Ext.data.ArrayReader({
fields: [
{ name: 'company' },
{ name: 'price', type: 'float' },
{ name: 'change', type: 'float' },
{ name: 'pctChange', type: 'float' },
{ name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia' }
]
})
});

// create the Grid
var grid = new Ext.grid.GridPanel({
store: store,
columns: [
{ id: 'company', header: "Company", width: 160, sortable: true, dataIndex: 'company' },
{ header: "Price", width: 75, sortable: true, renderer: 'usMoney', dataIndex: 'price' },
{ header: "Change", width: 75, sortable: true, renderer: change, dataIndex: 'change' },
{ header: "% Change", width: 75, sortable: true, renderer: pctChange, dataIndex: 'pctChange' },
{ header: "Last Updated", width: 85, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange' }
],
stripeRows: true,
autoExpandColumn: 'company',
height: 320,
width: 600,
frame: true,
title: 'Sliding Pager',

plugins: new Ext.ux.PanelResizer({
minHeight: 100
}),

bbar: new Ext.PagingToolbar({
pageSize: 10,
store: store,
displayInfo: true,

plugins: new Ext.ux.SlidingPager()
})
});

grid.render('grid-example');

store.load({ params: { start: 0, limit: 10} });
});