PDA

View Full Version : PAGINGTOOLBAR. HOW TO SEND EXTRA VARIABLES?



CHRISDEVELOPER
29 Oct 2009, 2:20 PM
:( HELP! I'M READY TO QUIT FOREVER!
Despite my best efforts, I've been unable to populate and send an extra variable along with the default "start" and "limit" when implementing a PagingToolbar on a Grid. The code below shows a combobox of state values (statecombo). The state value must be sent with every post to the database to retrieve data. The code does post the state value the first time a state is chosen from the combobox, however after that the paging doesn't work. I am using baseParams: {state: statecombo.value} in the store to retrieve the statecombo value and send it with each Post, however it isn't working for Paging. FIREBUG shows that it is posting the state as null or empty when you click the paging buttons.
POST
action listing
limit 20
start 20
state
Any idea of how to retrieve the state combobox value and send it with each Paging post?

- chris




var statecombo = new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
lazyRender:true,
mode: 'local',
emptyText:'Select a state...',
store: Ext.localdata.states,
valueField: 0,
displayField: 1,
listeners: {
select: function(){
store.load({
params: {
start: 0,
limit: 20,
state: this.value
}
})
}}
});


var

store =new Ext.data.JsonStore({


proxy:listproxy,

remoteSort:false,



baseParams:{state: statecombo.value, action:'listing'},



idProperty:'i_cust',

root:'data',

totalProperty:'totalCount',

fields:[

{name:'i_cust'}



,{name:'contact'}


,{name:'title'}

,{name:'comp_name'}

,{name:'address'}
...









]


});



var contactgrid =new Ext.grid.GridPanel({


store: store,


columns:[

{ id:'id', header:"ID", width:40, sortable:true, dataIndex:'i_cust'},



{ id:'contact', header:"Contact", width:100, sortable:true, dataIndex:'contact'},


{ id:'title', header:"Title", width:75, sortable:true, dataIndex:'title'},

{ id:'company', header:"Company", width:150, sortable:true, dataIndex:'comp_name'},

{ header:"Address", width:120, sortable:true, dataIndex:'address'},
... ],
stripeRows:true,








height:450,

width:950,

autoScroll:true,

autoExpandColumn:'company',


// paging bar on the bottom



bbar:new Ext.PagingToolbar({




pageSize: recordsperpage,

store: store,

buttonAlign:'right',

displayInfo:true,

displayMsg:'Displaying {0} - {1} of {2}',

emptyMsg:"No records to display"


})


});



var panel =new Ext.Panel(
{
...
items:[contactgrid]
});



panel.render('contactsdiv');


//FIRST TIME STORE LOADS




store.load({


params:{state: statecombo.value, start:0, limit:20, action:'listing'}



})

Animal
29 Oct 2009, 10:29 PM
Obviously at the time you call the ComboBox constructor, and your code assembles the config object to pass into it, when it comes to setting the <parameter>.params.state property of it for the ComboBox to use MUCH LATER, it attempts to pull the "value" property from the current this reference.

What IS the current this reference AT THE TIME THAT CONFIG OBJECT IS SET UP AND PASSED INTO THE CONSTRIUCTOR?

Really. Read your code and understand what it does.

Animal
29 Oct 2009, 10:32 PM
You might scan the docs for a possibility.

http://www.extjs.com/deploy/dev/docs/?class=Ext.form.ComboBox&member=queryParam