Results 1 to 3 of 3

Thread: how to get the store size in extjs 4

  1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    4

    Exclamation Answered: how to get the store size in extjs 4

    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 ?

  2. getCount() should tell you how many records are in it if you are executing it on the instance not the class definition.

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,448
    Answers
    3997

    Default

    getCount() should tell you how many records are in it if you are executing it on the instance not the class definition.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  4. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    4

    Exclamation the store is not getting loaded with the data, the count is always zero

    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 ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •