1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    8
    Vote Rating
    0
    sathish331977 is on a distinguished road

      0  

    Default Unanswered: Issue with Data stores in Sencha touch 2

    Unanswered: Issue with Data stores in Sencha touch 2


    I am trying to build a Tab based mobile app. I have 4 tabs Named 'Home','Call','Map','Notifications'. When i load the application i don't see the data in home tab. When i tap on other tab and comeback to home tab i can see data. This will work if i put a dummy tab as first tab( in my case i added 'Welcome' as first tab). I also noticed that when 'Home' is the first tab store is not loaded. The item array for 'Home' store is empty.
    When i tap on Maps and Notifications tab i don't see the data loaded.

    I have attached the code i am using.The tab application i developed is based on tab example i found in sencha examples.
    Can anyone please look into the code and point to me where i am doing wrong.
    Note: i have removed the sdk and resource folder as the size of the attachment is very big when including these two folder.We can copy sdk and resource folder by creating/existing project using sencha app create from command prompt
    Attached Files

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,224
    Answers
    3522
    Vote Rating
    859
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    How are you trying to load the data?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    8
    Vote Rating
    0
    sathish331977 is on a distinguished road

      0  

    Default


    It is in Home controller.

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,224
    Answers
    3522
    Vote Rating
    859
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Ok, in an event listener? In init?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User
    Join Date
    May 2012
    Posts
    131
    Answers
    7
    Vote Rating
    6
    klaus777 is on a distinguished road

      0  

    Default


    I had some similar problem, with setting up view elements programmatically from a store.
    My solution was to listen to the load event in the store and refresh the view after the store was loaded:
    Code:
    Ext.define('MyApp.store.Slides', {
    ....
    listeners: {
            'load' :  {
                fn : function(store,records,options) {
                    
                    // store finished loading, now lets refresh my view:
                     Ext.getCmp('detailview').refreshPool();
                },
                scope : this
            }
        }*/

    And your store should have autoLoad: true, so that it loads at app start :-)

  6. #6
    Sencha User
    Join Date
    Apr 2012
    Posts
    8
    Vote Rating
    0
    sathish331977 is on a distinguished road

      0  

    Default


    I have the following in my Init of controller
    init: function () {
    this.callParent(arguments);
    Ext.getStore('Home').load();
    }
    also i have added the following in "launch" and "onActivate" in controller
    var storeData = Ext.getStore('Home').load();
    var container = this.getHomeTabContainer();
    if (storeData != null) {
    var record = storeData.getAt(0);
    if (record != null) {
    var tpl = container.down('#pnlHome').getTpl(); //container.getTpl();
    var htmlstr = tpl.apply(record.data);
    container.setHtml(htmlstr);
    }
    }

    still it does not work.

    attached is my latest code
    Attached Files

  7. #7
    Sencha User
    Join Date
    Apr 2012
    Posts
    8
    Vote Rating
    0
    sathish331977 is on a distinguished road

      0  

    Default


    Any solution for this?

  8. #8
    Sencha User
    Join Date
    May 2012
    Posts
    131
    Answers
    7
    Vote Rating
    6
    klaus777 is on a distinguished road

      0  

    Default


    I once had a similar problem and my first workaround was to programmatically


    setActiveItem(1);
    setActiveItem(0);

    So changing the views programmatically (without any1 seeing it, because it changes back immediately) and so achieve to refresh the view and see the refreshed data in the view :-)


    Because I also figured out that my view didn't load and found out that it would only load when I change views (change tabs or whatever)...

    Not a good solution but at least its a solution :-)



    Another solution would be to try to sync the store so that the view, that has the store attached will also get synced I guess.

  9. #9
    Sencha User
    Join Date
    Apr 2012
    Posts
    8
    Vote Rating
    0
    sathish331977 is on a distinguished road

      0  

    Default


    for time being i have added another static ( which does not read from data store ) tab . Is this a bug in sencha touch2 or is this the expected behaviour?

Thread Participants: 2

Tags for this Thread