PDA

View Full Version : how to get the store size in extjs 4



vasuk
21 Mar 2012, 9:07 AM
I have a store below is the definition of my store

Ext.define('com.gm.vl.store.CompareVehicle', {
extend: 'Ext.data.Store',
model: 'com.gm.vl.model.CompareVehicle',
autoLoad: true,
proxy: {
type: 'ajax',
url : './app/data/CompareVehicle.json', // Local
reader: {
type: 'json',
root: 'compareVO',
successProperty: 'success'
}
}
});





, I need the size of the , I tried getCount(), data.length functions on store, its gives error no such defined

could anybody help me in getting the size of a store, should i do anything prior to call the above function ?

mitchellsimoens
21 Mar 2012, 10:14 AM
getCount() should tell you how many records are in it if you are executing it on the instance not the class definition.

vasuk
22 Mar 2012, 7:37 AM
my json object is as below

{
success: true,
"compareVO": [
{
"msrp": "",
"engine": "Engine",
"primaryColor": "PrimaryColor",
"peg": "PEG",
"transmission": "Transmission",
"trim": "Trim",
"model": "Model",
"vin": "vin"
},
{
"msrp": "msrp1",
"engine": " engine1",
"primaryColor": "PrimaryColor1",
"peg": "peg1",
"transmission": "transmission1",
"trim": "trim1",
"model": "model1",
"vin": "vin1"
},
{
"msrp": "msrp2",
"engine": " engine2",
"primaryColor": "PrimaryColor2",
"peg": "peg2",
"transmission": "transmission2",
"trim": "trim2",
"model": "model2",
"vin": "vin2"
}
],
"options": [
{
"optionType": "same",
"optionName": "option1",
"value1": "o1value1",
"value2": "o1value2",
"value3": "o1value3",
"value4": "o1value4"
},
{
"optionType": "different",
"optionName": "option2",
"value1": "o2value1",
"value2": "o2value2",
"value3": "o2value3",
"value4": "o2value4"
},
{
"optionType": "same",
"optionName": "option3",
"value1": "o3value1",
"value2": "o3value2",
"value3": "o3value3",
"value4": "o3value4"
},
{
"optionType": "different",
"optionName": "option4",
"value1": "o4value1",
"value2": "o4value2",
"value3": "o4value3",
"value4": "o4value4"
}
],
"vehicles":"3"
}


My store is as below

Ext.define('com.gm.vl.store.CompareVehicleBase', {
extend: 'Ext.data.Store',
model: 'com.gm.vl.model.CompareVehicle',
autoLoad: true,

proxy: {
type: 'ajax',
url : './app/data/CompareVehicle.json', // Local
reader: {
type: 'json',
root: 'compareVO',
successProperty: 'success'
}
}
});

my model is as below

Ext.define('com.gm.vl.model.CompareVehicle', {
extend: 'Ext.data.Model',
fields: ['msrp','engine','primaryColor','peg','transmission','trim',
'model','vin']

});


I am using the below statements to get the count

var myStore = Ext.StoreManager.lookup('CompareVehicleBase');
myStore.getCount(); is giving me always , myStore has no data in it

Could you please help me what the problem is ?