PDA

View Full Version : How to get TotalProperty value?



nick saint
8 Nov 2008, 2:53 AM
Hi, I am trying to get totalProperty value but cannot figure out how. I have:


// this is the combo for country

var PUcntr = new Ext.form.ComboBox({
store: PUcntrstore,
id: 'pucntr',
tpl: '<tpl for="."><div ext:qtip="{name}" class="x-combo-list-item">{name}</div></tpl>',
displayField:'name',
valueField: 'id',
fieldLabel: 'Country',
forceSelection: true,
triggerAction: 'all',
emptyText:'Select country ...',
maxHeight: 200,
selectOnFocus:true,
readOnly: true,
listeners:{
select:{fn:function(combo, value) {

PUloc.reset(); // locations combo
PUlocstore.proxy = new Ext.data.HttpProxy({url: 'location.php?cntr=' + combo.getValue()});
PUlocstore.load();

How can I check here the totalProperty value for PUloc?


}}
}
});

var PUlocstore = new Ext.data.Store({
//proxy: new Ext.data.HttpProxy({url: 'http://localhost/json/location.php'}), //cntr=1
reader: new Ext.data.JsonReader({
totalProperty: 'total',
root:'locations'
}, [{name: 'lid'}, {name: 'lname'}])
});

Thank you.

nick saint
8 Nov 2008, 4:12 AM
If I do like

PUlocstore.load();
var tot = PUlocstore.getTotalCount();
alert(tot);
it shows the totals for previosly selected item.
What's wrong?

nick saint
8 Nov 2008, 5:27 AM
Anyone? :-/

devnull
9 Nov 2008, 9:10 AM
store loads are asynchonous. you will need to put code like that into a load event listener, otherwise it will execute before the load completes, giving you data from the still valid previous load.