1. #1
    Sencha User Fire-Dragon-DoL's Avatar
    Join Date
    Dec 2011
    Posts
    141
    Answers
    9
    Vote Rating
    1
    Fire-Dragon-DoL is on a distinguished road

      0  

    Default Answered: How to handle a combobox that use the same store as a grid, which is filtering it?

    Answered: How to handle a combobox that use the same store as a grid, which is filtering it?


    I have a "stupid" problem, in my application I have (let's suppose) the store Comments and the store Authors. Comment has one author.

    Now, I have a grid to edit comments and one to edit authors, however when I'm editing the comments one and I use a combobox to choose the author, which use the same store as the authors grid, which may be filtered by the user for (example) name, the combobox appears filtered too.

    What are available solutions to keep the filtering on the authors grid while having "all" the authors (paged possibly) on the combobox?

  2. You shouldn't need to reload the store from the server. If you're using ExtJS 4.1 then records can be shared between multiple stores. You can have a master store that loads from the server and then create copies wherever you need those records. While the records will be shared the filtering and sorting will be specific to each store.

  3. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    My solution is to create a separate store for the combobox.

  4. #3
    Sencha User Fire-Dragon-DoL's Avatar
    Join Date
    Dec 2011
    Posts
    141
    Answers
    9
    Vote Rating
    1
    Fire-Dragon-DoL is on a distinguished road

      0  

    Default


    Quote Originally Posted by vietits View Post
    My solution is to create a separate store for the combobox.
    Actually I'm doing it too (I created a combobox that autogenerate a store). I hoped for a better solution anyway. Like storing filters and restoring them after

  5. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,069
    Answers
    673
    Vote Rating
    467
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Store is the best option ... and they are cheap .. just a few lines of code.

  6. #5
    Sencha User Fire-Dragon-DoL's Avatar
    Join Date
    Dec 2011
    Posts
    141
    Answers
    9
    Vote Rating
    1
    Fire-Dragon-DoL is on a distinguished road

      0  

    Default


    Quote Originally Posted by scottmartin View Post
    Store is the best option ... and they are cheap .. just a few lines of code.
    Yea but what "bothered" me is the fact that I have to reload it through the network, so I'm wasting bandwidth, it's not a matter of coding actually.

  7. #6
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,603
    Answers
    543
    Vote Rating
    325
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    You shouldn't need to reload the store from the server. If you're using ExtJS 4.1 then records can be shared between multiple stores. You can have a master store that loads from the server and then create copies wherever you need those records. While the records will be shared the filtering and sorting will be specific to each store.

  8. #7
    Sencha User Fire-Dragon-DoL's Avatar
    Join Date
    Dec 2011
    Posts
    141
    Answers
    9
    Vote Rating
    1
    Fire-Dragon-DoL is on a distinguished road

      0  

    Default


    Quote Originally Posted by skirtle View Post
    You shouldn't need to reload the store from the server. If you're using ExtJS 4.1 then records can be shared between multiple stores. You can have a master store that loads from the server and then create copies wherever you need those records. While the records will be shared the filtering and sorting will be specific to each store.
    That's REALLY interesting, two questions however:
    1. How does the master store behaves with filtering? I mean, if a child store request to filter, does this store require that this filter is implemented locally and not remotely?
    2. Last thing, how does this structure handle paging? Do I need to load ALL records? I'm afraid of loading tons of records. Imagine what happens if I have 30 000 records in a table... Expecially I used remote filtering actually to reduce records, and I can't imagine how child stores handles this (no problem in changing, just I want to understand how to face "tons of records" problem)

  9. #8
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,603
    Answers
    543
    Vote Rating
    325
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Don't dwell too much on the term 'master store'. I really just mean a source store that already contains the records you want.

    All I'm really saying is that you can take the records in one store and add them to another store to avoid having to make an extra request to the server. If you also want to copy the filtering or paging state from one store to the other then obviously you can but it'll make things much more complicated. Once the second store is created there isn't an on-going link back to the original store unless you choose to create one.

  10. #9
    Sencha User Fire-Dragon-DoL's Avatar
    Join Date
    Dec 2011
    Posts
    141
    Answers
    9
    Vote Rating
    1
    Fire-Dragon-DoL is on a distinguished road

      0  

    Default


    Quote Originally Posted by skirtle View Post
    Don't dwell too much on the term 'master store'. I really just mean a source store that already contains the records you want.

    All I'm really saying is that you can take the records in one store and add them to another store to avoid having to make an extra request to the server. If you also want to copy the filtering or paging state from one store to the other then obviously you can but it'll make things much more complicated. Once the second store is created there isn't an on-going link back to the original store unless you choose to create one.
    Maybe the fact that I can just copy data is even better: I'll check if filters are applied (if that's the case I basically reload everything in the "child" store directly from the server), if not, I copy all available data. Thanks.

    Can you post (if it's really short) how to make this data copy from store to store?

  11. #10
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,603
    Answers
    543
    Vote Rating
    325
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Code:
    newStore.add(oldStore.getRange());