PDA

View Full Version : load store with params



mohaskuar
19 Jun 2012, 11:03 PM
hi, am new to ext 4. i want to load a store with params that can pass the start & limit of my query in database.php..... actually the code works in extjs 3 but not in extjs 4,
here is my code
var store = new Ext.data.JsonStore({
totalProperty: 'total',
root: 'results',
url: 'database.php',
fields: [
{name: 'id', type: 'int'},
'text', 'parent_id'
]
});


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

please...:-/

ociowaty
19 Jun 2012, 11:37 PM
store.getProxy().extraParams.start= 0;
store.load();

scottmartin
20 Jun 2012, 12:52 PM
Your call should work fine.. what problem are you having? Does the header contain the info?



store.load(
{
params: {
start: 0,
limit: 25,
sort: '[{"property":"id_request","direction":"DESC"}]' // defined in model as object
}
});


Scott.

mohaskuar
21 Jun 2012, 5:08 AM
for sure it was a silly mistake but i figured it out and this my be helpfully for some one who is going to have a problem like me....here is the code


var store=Ext.create('Ext.data.Store', {
model: 'User',
loadMask: true,
//method: 'GET',
pageSize: 10,
proxy: {

type: 'ajax',
url : 'grid.php',

reader: {
type: 'json',
root: 'results',
totalProperty: 'total'
},
actionMethods:'POST' //
}
});

var par = new Object();
par['start'] = 0;
par['limit']=10;
store.load({params: par});

and at the end of database.php you have to echo "out" the json out put like this.
echo '({"total":"'.$totaldata.'","results":'.json_encode($data).'})';
and this works fine,in extjs4