Results 1 to 5 of 5

Thread: Store showing count as zero even after loading

  1. #1

    Default Store showing count as zero even after loading

    Hi,
    I am facing a peculiar problem.

    I am defining a store as below.
    var store = new Ext.data.GroupingStore({
    proxy: proxy,
    reader: reader,
    sortInfo: { field:
    'testField', direction: "ASC" },
    groupField:
    'testField'
    });
    store.load({
    params: {
    query:
    'null'
    }
    });

    Now after this if i get the count by the store.getCount() method , it is showing as zero,
    but when i give this store to a grid, the data is being displayed.

    Please help me out if i am missing anything.
    Thanks in advance.

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,253

    Default

    Ajax is asynchronous, by the time you call getCount, the store hasn't loaded yet. Execute the call to getCount inside the "load" listener on the store.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3

    Default Store showing count as 0

    Hi Evan,
    Thanks for the reply.
    I need to do a query on the store once it is loaded and take the data to a text field on the UI, now can you please let me know if i can make a wait call or some thing while the store loads.

    TIA.
    Regards
    Harsha

  4. #4
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,253

    Default

    Please read my previous post:

    Execute the call to getCount inside the "load" listener on the store.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  5. #5
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    This information is displayed in bold to attempt to overcome this Frequently Asked Question:


Posting Permissions

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