Results 1 to 3 of 3

Thread: Same store want all records in grid but only first ten in chart?

  1. #1
    Sencha User
    Join Date
    Mar 2011
    Posts
    24

    Question Same store want all records in grid but only first ten in chart?

    How would I achieve this?

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,436

    Default

    If you share a store, if you make changes to that store in one widget it will be reflected in the other widget.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

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

  3. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    24

    Question

    If I can't use the same store then that made me think can I copy the store but just the first ten records. Ideally everytime the first store loads it then copies the ten records to the second store.


    I got this to work but with my limited knowledge the code below is a mess and loads the store twice. I tried within the copy store function to only load 10 records but always loaded them all so I had to do an on load on the second store then add the slice. I'm sure there is much better way around doing this?

    Or I just give up with this idea and have 2 stores independent of each other and one just loads ten records from the database. If I do so can I use the same model for more than one store, so far in my mvc app I always have one model per store.

    Code:
     function copyStore (store, model){
      var records = [];
      var newStore = new Ext.data.Store(
       {
       model : model
       });
      store.each(
       function (r)
       {
       records.push (r.copy());
       }
       );
      newStore.loadRecords(records);
      return newStore;
      }; 
      
      var ds = Ext.getStore('ItemclassChart');  
         ds.load();
      
      ds2 = copyStore(ds,'AM.model.ItemclassChart');
      ds2.load();
      ds2.on('load', function (store,records) {
      ds2.loadData(records.slice(0,10));
     });

Posting Permissions

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