PDA

View Full Version : Why paging doesn't works



ing.amdangelo
13 Feb 2012, 11:54 PM
var toolbarGridConv = Ext.create('Ext.PagingToolbar', {
store: strConvegni,
displayInfo: true,
displayMsg: 'Elementi visualizzati da {0} a {1} di {2}',
emptyMsg: "Nessun elemento trovato"
})


var listaConv = Ext.create('Ext.grid.Panel', {
loadMask: true,
store: strConvegni,
layout:'fit',
columns: [
{
id: 'comune',
name: 'comune',
header: 'Comune',
sortable: true,
dataIndex: 'comune'
},
{
id: 'provincia',
name: 'provincia',
header: 'Provincia',
sortable: true,
dataIndex: 'provincia',
hidden: false
},
{
id: 'data',
name: 'data',
header: 'Data',
sortable: true,
dataIndex: 'data',
renderer: Ext.util.Format.dateRenderer('d/m/Y')
},
{
id: 'titolo',
name: 'titolo',
header: "Convegno",
sortable: true,
flex: 1,
dataIndex: 'titolo'
},
{
id: 'numAdesioni',
name: 'numAdesioni',
header: "Tot. Ades.",
sortable: true,
align: 'center',
dataIndex: 'numAdesioni'
},
{
id: 'limiteAdesioni',
name: 'limiteAdesioni',
header: "Max Ades.",
sortable: true,
width:70,
align: 'center',
dataIndex: 'limiteAdesioni',
renderer: function (_val) {
var ret = "<b>" + _val + "</b>";


if (_val == -1) {
ret = "No";
}


return ret;
}
},
{
id: 'tipologia',
name: 'tipologia',
header: "Tipologia",
sortable: true,
dataIndex: 'tipologia',
align: 'center',
width: 110,
renderer: function (_val) {
var ret = "<b>" + _val + "</b>";
return ret;
}
},
{
id: 'biennio',
name: 'biennio',
header: "Biennio",
sortable: true,
dataIndex: 'biennio',
align: 'center',
width: 70,
renderer: function (_val) {
var ret = "<b>" + _val + "</b>";
return ret;
}
}
],
bbar:toolbarGridConv
});

The first page it's right but when i try to load the others pages doesn't works,

Farish
14 Feb 2012, 12:18 AM
Are you sure that the backend it handling paging like its supposed to? Adding paging to grid and store will only cause the paging parameters (start and pageSize) to be appended to the request that is sent. However, the server must read these parameters and send a response with the desired records.

Also post the code of your store and please using CODE tages (the hash symbol) when you enter code.

ing.amdangelo
14 Feb 2012, 12:36 AM
Can you explain how to send extra parameters ??
'cause when i load the store, i send to the server extra parameters, but while in extjs 3, if the base param of the store is empty

var strConvegni = new Ext.data.XmlStore({
url: 'ajax.asmx/getConvByAdminProv',
record: 'Convegno',
idPath: 'Id',
//totalRecords: '@Totale',
fields: [{ name: 'Id', mapping: 'Id' },
{ name: 'titolo', mapping: 'titolo' },
{ name: 'provincia', mapping: 'provincia' },
{ name: 'comune', mapping: 'comune' },
{ name: 'data', type: 'date', dateFormat: 'd/m/Y' },
{ name: 'numAdesioni', mapping: 'numAdesioni' },
{ name: 'limiteAdesioni', mapping: 'limiteAdesioni' },
{ name: 'tipologia', mapping: 'tipologia' },
{ name: 'biennio', mapping: 'biennio' },
{ name: 'crediti', mapping: 'crediti'}]
});

strConvegni.baseParams = { _idAdmin: idAdmin, _provincia: provincia, _flagElim: false, sort: 'data', dir: 'DESC', start: 0, limit: 28 };

How to obtain the same thing in ext 4 ??

Farish
14 Feb 2012, 1:05 AM
You could configure your store like:


var strConvegni = new Ext.data.XmlStore({
url: 'ajax.asmx/getConvByAdminProv',
pageSize: 30, buffered: false, purgePageCount: 0,
remoteSort: true, remoteFilter: true,
record: 'Convegno',
idPath: 'Id',
//totalRecords: '@Totale',
fields: [{ name: 'Id', mapping: 'Id' },
{ name: 'titolo', mapping: 'titolo' },
{ name: 'provincia', mapping: 'provincia' },
{ name: 'comune', mapping: 'comune' },
{ name: 'data', type: 'date', dateFormat: 'd/m/Y' },
{ name: 'numAdesioni', mapping: 'numAdesioni' },
{ name: 'limiteAdesioni', mapping: 'limiteAdesioni' },
{ name: 'tipologia', mapping: 'tipologia' },
{ name: 'biennio', mapping: 'biennio' },
{ name: 'crediti', mapping: 'crediti'}]
});

This way, when you click on the next page, the store will automatically append the parameters for start and limit (depending on pageSize). You will probably also have to do sorting and filtering (if you desire it) on the server side since not all data is available on the client side when paging is used.