Results 1 to 4 of 4

Thread: Copy, Duplicate or Clone Store (ExtJs 4)

  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    19
    Answers
    1
    Vote Rating
    0
      0  

    Default Answered: Copy, Duplicate or Clone Store (ExtJs 4)

    Hey!

    I have a store from a json file that i want copied. How is this done!?

    Some help is available for this but I am not able to do it with ExtJS 4.

    Code:
    var newStore= new Ext.data.Store({
            model : oldStoreModel
    });
    oldStore.each(function (r){
            records.push (r.copy());
    }); 
    newStore.loadRecords(records);
    In the above the newStore is empty...

  2. well, a store definitely should get more configs than just a model definition and you should not pass that one in via reference.

    i would go the mvc way: create a custom class for your model using Ext.define(). Create a class for you store as well using the model. Create a new instance (using Ext.create() instead of new) of the store, then you can load the data from the first store.

    tip:
    http://docs.sencha.com/ext-js/4-0/#!...n_architecture
    -> Creating a Model and a Store

  3. #2
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,751
    Answers
    130
    Vote Rating
    129
      0  

    Default

    well, a store definitely should get more configs than just a model definition and you should not pass that one in via reference.

    i would go the mvc way: create a custom class for your model using Ext.define(). Create a class for you store as well using the model. Create a new instance (using Ext.create() instead of new) of the store, then you can load the data from the first store.

    tip:
    http://docs.sencha.com/ext-js/4-0/#!...n_architecture
    -> Creating a Model and a Store
    Best regards
    Tobias Uhlig

  4. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    19
    Answers
    1
    Vote Rating
    0
      0  

    Default

    Hehehe... Not so simple I see...

    I need this in order to show only part of the records of a store in a graph. Ill just go with plan B and generate an optimized json for the graph...

    Nevertheless, thank you for your reply.

  5. #4
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,751
    Answers
    130
    Vote Rating
    129
      0  

    Default

    you can also filter the store ->

    store.filter()
    store.filterBy()

    the approach to create reuseable components is not difficult to implement.
    Best regards
    Tobias Uhlig

Posting Permissions

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