1. #1
    Sencha User
    Join Date
    Mar 2010
    Posts
    15
    Vote Rating
    0
    allansun is on a distinguished road

      0  

    Default Set Filter at the time Grid is initialised

    Set Filter at the time Grid is initialised


    Hi guys,

    I want to set some default filters (Ext.ux.grid.FiltersFeature) when my grid is created, so it's like default filters to the grid, user can change the filter after grid is created.

    extjs.png

    The problem is : Filters are not initialised until user click the trigger on the column, so I cannot set default values to the filter.

    I tried to fireEvent on the column but it doesn't seem to help.

    Is there any way I can set default filters ?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,525
    Vote Rating
    871
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Have you tried to set filters on the store to see if the filter feature picks it up?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Mar 2010
    Posts
    15
    Vote Rating
    0
    allansun is on a distinguished road

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    Have you tried to set filters on the store to see if the filter feature picks it up?
    I checked the Ext.util.Filter but don't see relevant options for setting things like date range or list, is there a way to do so?

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,525
    Vote Rating
    871
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by allansun View Post
    I checked the Ext.util.Filter but don't see relevant options for setting things like date range or list, is there a way to do so?
    You would need to do that yourself by adding multiple filters.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User
    Join Date
    Mar 2010
    Posts
    15
    Vote Rating
    0
    allansun is on a distinguished road

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    You would need to do that yourself by adding multiple filters.
    I have tried that but it seems Store filter and Grid Filter are using different mechanisms, Grid Filter won't pick up the store filter setting.

  6. #6
    Sencha Premium Member
    Join Date
    Sep 2010
    Posts
    7
    Vote Rating
    0
    andyproxis is on a distinguished road

      0  

    Exclamation same problem

    same problem


    Hello,

    I have same problem. I need to load window with grid which is already filtered. I had luck with setting filters - i have it set, but to make it work i need to add another filter, even my filters are already set. Also I cant read them with getFilters function. Seems like filters are not initialised until i go with mouse and click on filter menu. After this action, I can read getFilters function.

    So its some bug ? Or how can I solve this problem ?

    Also I need remote sort, remote filtering.

    Thanks for ANY response.

    BR,
    Andy

  7. #7
    Sencha User
    Join Date
    Mar 2007
    Posts
    10
    Vote Rating
    0
    Lod is on a distinguished road

      0  

    Default Any follow-up on this one?

    Any follow-up on this one?


    Any progress on this one for 4.0.7?

    On sorting, the header changes into bold, but the filter is not applied.

    As a not-working default filter is a stopper for us, could we get some feedback or workaround?
    Has it to do with the order in which the grid, the filter and the store are rendered?
    Could we solve this with an onRender override? (How?)

    Thanks,

    Lod

  8. #8
    Sencha Premium Member
    Join Date
    Sep 2010
    Posts
    7
    Vote Rating
    0
    andyproxis is on a distinguished road

      0  

    Default


    same problem... still looking for working solution...

  9. #9
    Ext JS Premium Member
    Join Date
    Feb 2011
    Posts
    36
    Vote Rating
    1
    christianb is on a distinguished road

      0  

    Cool


    this does the job for me:

    Code:
       progressStore.prefetch({
                            start : 0,
                            limit : 99,
                            callback : function() {
                                progressStore.guaranteeRange(0, 49);
                                // Apply Initial Filter for column with dataIndex 'name' and Initial value 'initValue'
                                if (progressGrid.filters != null) {
                                    var gridFilters = progressGrid.filters;
                                    gridFilters.createFilters();
                                    var filter = gridFilters.filters.get('name');
                                    filter.setActive(true);
                                    var field = gridFilters.getFilter('name');
                                    if (field != null) {
                                        field.setValue('initValue');
                                    }
                                    gridFilters.updateColumnHeadings();
                                }
                            }
                        });

  10. #10
    Sencha User
    Join Date
    May 2012
    Posts
    5
    Vote Rating
    0
    Joshua Pruitt is on a distinguished road

      0  

    Default


    An old thread, I'm aware, but I'm flummoxed by this myself.

    Regarding the mechanisms that are different for the store's filter versus the grid's filter, this is confusing in and of itself.

    If I activate the store filter, my store's query string parameters (passed to an Ajax handler) get passed like this:

    Code:
    page: 0
    start: 0
    limit: 50
    filter: [{"property": "foo", "value": "bar"}]
    Whereas if I use the grid filter, if looks like this:

    Code:
    page: 0
    start: 0
    limit: 50
    filter: [{"field": "foo", "value": "bar", "type": "string"}]
    So that's confusing of itself. I could adjust my server-side responder to listen for "property" if I activate the store filter, but then a user may grid filter the thing afterwards, and I'd have to listen for "field". Why the difference?

    I'd like to just use the grid filter if I could, since that's what the client interacts with and I'd only have to listen for "field" (and updating the store's filter doesn't update the grid filter display, which I need it to do), but I'm not having any luck setting things programmatically for it and having it actually filter anything. I've tried grid's initComponent(), afterrender(), and so on. I get some variant of instance (grid.filters) undefined [like when I call this.filters.getFilter('foo')], or a filter's setValue() and setActive() methods simply not doing anything in regards to the grid.

    What's the correct, Ext.js-idiomatic way to do this? I'm also attempting to use MVC, FWIW.