PDA

View Full Version : [Solved] Trouble with Grid Paging and additional params



amegahed
3 Aug 2009, 8:07 AM
Im using a php page which has all my queries based on a queryid that i pass to it. this is how i load the store the first time:

dsMovies.load({params:{start: 0, limit: 25, queryid: 201}});


and this is my store:

var dsMovies = new Ext.data.JsonStore({
totalProperty : 'total',
root : 'results',
url : 'php/myqueries.php',
fields : [
{name: 'movieid', type: 'int'},
'moviename', 'moviegenre', 'movieyear', 'movieoutline', 'movieplot', 'movieimdbid', 'movieposter',
'moviedirector', 'movierating'
]
});


and this is the pagingtoolbar

var pbarMovies = new Ext.PagingToolbar({
pageSize: 25,
store: dsMovies,
displayInfo: true,
displayMsg: 'Displaying {0} - {1} of {2}',
emptyMsg: "No Movies to display"
});


when the page loads, i can see from firebug that the posted params are:


limit 25
queryid 201
start 0


but when i press the next button on the paging toolbar this the params that are sent (seen from firebug)


limit 25
start 25


and i get no results back? any thoughts?

amegahed
3 Aug 2009, 8:45 AM
I reverted to the old way i had my queries setup, using the GET:


var dsMovies = new Ext.data.JsonStore({
totalProperty : 'total',
root : 'results',
url : 'php/myqueries.php?queryid=201',
method : 'post',
fields : [
{name: 'movieid', type: 'int'},
'moviename', 'moviegenre', 'movieyear', 'movieoutline', 'movieplot', 'movieimdbid', 'movieposter',
'moviedirector', 'movierating'
]
});


and if i need to change the queryid i use:


dsMovies.proxy.conn.url = 'php/myqueries.php?queryid=702';
dsMovies.load({params:{start: 0, limit: 25, var1: el.getValue()}});


which works.. but i still would like to know how can i make it work using POST

carol.ext
3 Aug 2009, 8:47 AM
Look at baseParams, setBaseParam() in JsonStore API (http://extjs.com/deploy/dev/docs/?class=Ext.data.JsonStore)

See Grid FAQ section on sending additional data with baseParams (http://extjs.com/learn/Ext_FAQ_Grid#Sending_additional_data). setBaseParam() is new to 3.0, I don't think it is mentioned in Grid FAQ.

amegahed
3 Aug 2009, 9:17 AM
That is very funny :) I read about baseParams during my search and i already tried it earlier today, but for some reason it did not work :-? but i thought now that you mentioned it, maybe i should give it another try.. and it worked :)


var dsMovies = new Ext.data.JsonStore({
totalProperty : 'total',
root : 'results',
url : 'php/myqueries.php',
baseParams : { queryid: 201},
method : 'post',
fields : [
{name: 'movieid', type: 'int'},
'moviename', 'moviegenre', 'movieyear', 'movieoutline', 'movieplot', 'movieimdbid', 'movieposter',
'moviedirector', 'movierating'
]
});