1. #1
    Sencha User
    Join Date
    Feb 2013
    Location
    NZ
    Posts
    74
    Answers
    5
    Vote Rating
    0
    mazhar.shaikh is on a distinguished road

      0  

    Default Answered: Hiding records in Store and display on grid

    Answered: Hiding records in Store and display on grid


    Hi,
    Currently what I have:
    currentGrid.JPG

    One long list of months and their Sales Qty.

    What I want to achieve:
    expected.JPG

    I want only 6 rows on the grid and then the remaining months adjacent first ones and so on.

    How I plan to implement:
    Number of Total Rows in Store : 24
    Total Rows on Grid: 6
    Number of Grids: 4

    I have 4 stores A, B, C, D (exact duplicates) using same model. On the View, I have 4 grids GridA and GridB. GridC, GridD using A and B, C and D respectively.

    Now I want to filter and hide rows on grids accordingly:
    A B C D
    1 7 13 19
    2 8 14 20
    3 9 15 21
    4 10 16 22
    5 11 17 23
    6 12 18 24

    How do I achieve this?

    Is this the best way I can do this? I dont want to modify my server messaging. Is there any other way that I could do this.

    Thanks. Appreciate any assistance.

  2. Thanks for your answer mate. I had no patience to wait for a day, so I ended up changing my server response and modified my model accordingly to achieve that. But your suggestion is way to simpler and involves less effort (assuming it will do the job that I want to achieve, worth a try).

    Thanks

  3. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,099
    Answers
    113
    Vote Rating
    96
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      0  

    Default


    I dont know if there is a better way to do it but for filtering, you can use filter function:

    Code:
    var monthIdFilter = new Ext.util.Filter({
      filterFn: function(item) {
        return item.data.monthId > 6; // you have to create a different function with different conditions here for each store.
      }    
    });
    
    store.filter(monthIdFilter);

  4. #3
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,099
    Answers
    113
    Vote Rating
    96
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      1  

    Default


    One other possibility is that since you are using independent stores for each grid, you can load one main store which contains all records, sort them on load event and push e.g. first 6 records into storeA and so on:

    Code:
    store.on('load', function() {
      store.sort('id', 'ASC');
      var allRecords = store.getRange();
      for(var i=0; i<allRecords.length; i++)
      {
        if(allRecords[i].get('id') < 6)
          storeA.add(allRecords[i]);
        else if...
      }
    });

  5. #4
    Sencha User
    Join Date
    Feb 2013
    Location
    NZ
    Posts
    74
    Answers
    5
    Vote Rating
    0
    mazhar.shaikh is on a distinguished road

      0  

    Default


    Thanks for your answer mate. I had no patience to wait for a day, so I ended up changing my server response and modified my model accordingly to achieve that. But your suggestion is way to simpler and involves less effort (assuming it will do the job that I want to achieve, worth a try).

    Thanks

Thread Participants: 1

Tags for this Thread