Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: set store to list in controller

  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    86
    Answers
    2
    Vote Rating
    0
      0  

    Default set store to list in controller

    Can any body help me with setting store to List in controller for sencha touch 2 mvc structure application.

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3932
    Vote Rating
    1272
      0  

    Default

    In your controller, execute setStore on the list instance passing in the new store.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    86
    Answers
    2
    Vote Rating
    0
      0  

    Default

    I thing store object is instantiated, but data is not coming. How can I check in store data is coming or not.

  4. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3932
    Vote Rating
    1272
      0  

    Default

    console.log your store and inspect it. Or simple use store.getCount() to see if it has items in it.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  5. #5
    Sencha User
    Join Date
    Feb 2012
    Posts
    86
    Answers
    2
    Vote Rating
    0
      0  

    Default

    I checked using store.getCount(), its giving me 0, even if data is present.

  6. #6
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3932
    Vote Rating
    1272
      0  

    Default

    Are you checking within a load listener or callback or right after you do a store.load?

    Code:
    store.load({
        success : function(store) {
            console.log(store.getCount());
        }
    });
    
    store.on('load', function(store) {
        console.log(store.getCount());
    }, store);
    store.load();
    
    new Ext.data.Store({
        ....
        listeners : {
            load : function(store) {
                console.log(store.getCount());
            }
        }
    });
    Those are 3 ways to do it. This is the wrong way to do it:

    Code:
    store.load();
    console.log(store.getCount());
    The request is still being executed when the getCount executes.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  7. #7
    Sencha User
    Join Date
    Feb 2012
    Posts
    86
    Answers
    2
    Vote Rating
    0
      0  

    Default

    I have added store in stores array in Ext.application, then checked it in launch function in controller.

  8. #8
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3932
    Vote Rating
    1272
      0  

    Default

    Quote Originally Posted by alohainc View Post
    I have added store in stores array in Ext.application, then checked it in launch function in controller.
    Has the store finished it's loading by then?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  9. #9
    Sencha User
    Join Date
    Feb 2012
    Posts
    86
    Answers
    2
    Vote Rating
    0
      0  

    Default

    I have store with autoLoad true, do I need to load it again in my controller? and the three methods you have given to check, where should I add those function?

  10. #10
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3932
    Vote Rating
    1272
      0  

    Default

    Quote Originally Posted by alohainc View Post
    I have store with autoLoad true, do I need to load it again in my controller? and the three methods you have given to check, where should I add those function?
    No, just if your controller's launch method fires before the store's loading is done, then the count of the store is going to be zero.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Page 1 of 2 12 LastLast

Posting Permissions

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