1. #1
    Sencha User
    Join Date
    May 2011
    Location
    Belgium
    Posts
    16
    Vote Rating
    0
    julien.meyer is on a distinguished road

      0  

    Default Unanswered: One instance of Model belong to multiple Stores

    Unanswered: One instance of Model belong to multiple Stores


    I need to share a model instance between two stores (a TreeStore and a Store).
    A model instance can only have a reference to one store. I can listen the update event and propagate it to the other store but it need configuration, coding, ...
    I search into the forum but I didn't find anything. In a old Ed Spencer post http://edspencer.net/2011/02/proxies-extjs-4.html. He said that I will be possible to do it in 4.0 (in february 2011). But I think that it's not yet available...
    Anyone know if it's possible to share instance between multiple stores ?

  2. #2
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,684
    Answers
    130
    Vote Rating
    112
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      0  

    Default


    multiple stores can use the same model class.

    i do not think it makes sense to share an instance -> if one store gets a filter, is cleared, loaded etc. you get problems.

    you can share one store instance with multiple views.
    Best regards
    Tobias Uhlig
    __________

    S-CIRCLES Social Network Engine

  3. #3
    Sencha User
    Join Date
    May 2011
    Location
    Belgium
    Posts
    16
    Vote Rating
    0
    julien.meyer is on a distinguished road

      0  

    Default


    Hi Tobiu,

    I'm agree with you that, in some case, you didn't need to share instance. Filter is a good example.
    But in some case, it's important (or easier) to share instance.
    Example : a file browser. A tree to show the directory and a grid to show files and subfolders. If you change a subfolder name, it's nice if the node corresponding to this subfolders is automatically updated without listening store update event.

  4. #4
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,684
    Answers
    130
    Vote Rating
    112
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      0  

    Default


    hmm,

    using the same store (instance) would be not easy to implement, since you have a treeStore for the tree and a plain store for the grid.

    you can put all the data into the treeStore and fill the grid store on a node selection with the relevant subData. imho the easiest way to go. if the data is huge, i would only load the parent nodes for the tree and fetch the needed grid data via ajax on demand.
    Best regards
    Tobias Uhlig
    __________

    S-CIRCLES Social Network Engine

  5. #5
    Sencha User
    Join Date
    May 2011
    Location
    Belgium
    Posts
    16
    Vote Rating
    0
    julien.meyer is on a distinguished road

      0  

    Default


    I take a look into the model class and it's possible to extend it to use an collection of store. But I don't know the side effects...

    Currently, we use the solution you describe in your post. So we got the same idea ;-)

Thread Participants: 1

Tags for this Thread