Results 1 to 3 of 3

Thread: One Store to Rule Them All

  1. #1
    Sencha User
    Join Date
    Feb 2012
    Location
    Illinois
    Posts
    97
    Vote Rating
    2
      0  

    Default One Store to Rule Them All

    Hello,

    I have 3 stores:
    Urls : manage the urls that the dynamic store can get it's data from.
    MyDataItems : a store which loads data from multiple locations into a single model.
    MySuperDataItems : which is associated with a MyDataItem model which I populate manually when the MyDataItems store loads via a customLoad method.

    Urls contains the list of Url models that a user can select or deselect and MyDataItems is the store associated to the MyDataItem model.

    Then I am able to iterate Urls.each and dynamically apply the url stored there to the MyDataItmes store and load the data.

    I am then able to define a list with a store property of MySuperDataItems and call the customLoad and all is well.

    I have run into a couple issues with this approach.

    Gatchas : (There are likely quite a few more I won't remember as I've worked on this for a while.)

    1) Sorting...
    I ran into some trouble getting the store to sort for me. Finally got it to work by sorting inside MySuperDataItems iteration/loading of MyDataItems. I optimized this a little by only sorting on the last item in the list.

    2) PullToRefresh...
    If I try to apply the PullRefreshPlugin the load method is never called because the load is dynamic based on another store and called manually by MySuperDataItems.customLoad();
    I added a refreshFn to the plugin that calls the customLoad on MySuperDataItems.

    3) Adding the items to MySuperStoreDataItems...
    I went through a few hours of looking at the different methods available for adding items manually to a store and finally went with MySuperDataItems.add(MyDataItems.each())...or something similar, this is all obviously psudo-code.

    Let me know if this helps anyone or post questions if you have them....or especially if you have suggestions for improvement!

    Thanks,

    bwags

  2. #2
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,183
    Vote Rating
    1442
      0  

    Default

    1. Why are you having trouble sorting?
    2. Seems like you would need to extend the plugin and handle things to suit your needs
    3. You can iterate through a store and add to another store using record.getData()
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

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

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Location
    Illinois
    Posts
    97
    Vote Rating
    2
      0  

    Default

    I ended up getting everything to work...I was mostly just posting this in case anyone else wanted to do something similar. I was able to resolve all of the 'gatchas' with the solutions I posted beneath them, again in case anyone else was having similar issues.

Tags for this Thread

Posting Permissions

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