1. #1
    Sencha User
    Join Date
    Oct 2012
    Location
    India
    Posts
    15
    Vote Rating
    1
    Answers
    1
    saurabh0683 is on a distinguished road

      0  

    Default Unanswered: trying to use setAvtive in AbstractGridFilters for applying grid filters externally

    Unanswered: trying to use setAvtive in AbstractGridFilters for applying grid filters externally


    Hi,
    I'm trying to apply filters for Grid data externally through custom code instead of using Grid context menu.
    the API seem simple enough as,
    StringFilter<Film> descFilter = new StringFilter<Film>(filmProps.description());
    //...
    nameFilter.setValue("do");
    nameFilter.setActive(true, true);
    //...

    this code executes on button click and appropriate log is also displayed using GWT.log() but still no effect of filter.
    But on clicking button second time filters are applied. What could be reason for this?

    Please let me know if code snippet mentioned above is sufficient for applying string filters?
    Attached Images

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,734
    Vote Rating
    90
    Answers
    109
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    It looks like you might be using GXT 2, but you've posted in the GXT 3 forums - which version are you using?

    The StringFilter class is designed to make it easy for a user to type in values to manipulate what items are shown in the grid - if you want to modify the filter settings programmatically, use the methods on the Store that involve filtering - these vary depending on which version you are using.

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Location
    India
    Posts
    15
    Vote Rating
    1
    Answers
    1
    saurabh0683 is on a distinguished road

      0  

    Default


    thanks for replying Colin.
    I'm certain that it is gxt 3.0

  4. #4
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,734
    Vote Rating
    90
    Answers
    109
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      1  

    Default


    There is no StringFilter.setValue call in GXT 3.

    To add a filter to a GXT 3 store, you'll do something like this:
    Code:
    store.addFilter(new StoreFilter<Film>() {
      public boolean select(Store<Film> store, Film parent, Film item) {
        return item.getDescription().contains("do");
      }
    });
    store.setEnableFilters(true);
    You can build any implementation of StoreFilter that you want to be able to run specific queries.

  5. #5
    Sencha User
    Join Date
    Oct 2012
    Location
    India
    Posts
    15
    Vote Rating
    1
    Answers
    1
    saurabh0683 is on a distinguished road

      0  

    Default


    Thanks Colin
    Solution you gave works gr8. But my question was w.r.t. grid filters provided on grid columns context menu in FilterGrid example in the demo:
    http://www.sencha.com/examples/#ExamplePlace:filtergrid

    this example provides good functionality of filter on column itself like in excel, setting filtered column name in bold/italics and indicating the filter value.
    But I was also trying control it from outside panel. So i referred to AbstractGridFilters class.
    Interesting methods observed onStateChange() and StoreFilter's select()
    By overriding i caould have filtering on grid but with unpredictable behaviour.

    Please suggest if this approach was right or not.

  6. #6
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,734
    Vote Rating
    90
    Answers
    109
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    I'm not sure I understand exactly what you are asking - what is the unpredictable behavior you are worried about?

  7. #7
    Sencha User
    Join Date
    Oct 2011
    Location
    LA
    Posts
    25
    Vote Rating
    1
    Answers
    1
    ByReaL is on a distinguished road

      0  

    Default


    grid_filter.jpg


    how can i set "abc" through the code in GXT3 ?

    same problem here with GXT 3.0.1 i want to set the value of the grid filter and i want to enable the grid filter

    for example i press a button and automatically the gridd filter is set to a certain value,

    in GXT2 i was doing
    someStringFilter.setValue((String) aFilterWord)
    and it was working like a charm. (the content of aFilterWord was placed in the filter in the grid header and the user could see what i set)

    in GXT3 i do
    Info.display("Debug",someStringFilter.getFilterConfig().get(0).getValue());
    and if i go to the grid and manually set the filter (from the grid header) when i triger that info things it's printing the value of the filter properly

    in GXT3 if i do
    someStringFilter.getFilterConfig().get(0).setValue((String) aFilterWord)
    nothing happens, not even
    Info.display("Debug",someStringFilter.getFilterConfig().get(0).getValue());
    does not display the content of aFilterWord and in the UI if i look at the grid header filter is nothing in there.

  8. #8
    Sencha User
    Join Date
    Oct 2011
    Location
    LA
    Posts
    25
    Vote Rating
    1
    Answers
    1
    ByReaL is on a distinguished road

      0  

    Default


    anyoane any idea if someStringFilter.getFilterConfig().get(0).setValue((String) aFilterWord) is broken or i'm missuing it ?

  9. #9
    Sencha User
    Join Date
    May 2014
    Posts
    0
    Vote Rating
    0
    Ogeeon is on a distinguished road

      0  

    Default


    It's sure too late for the TS, but I'd like the information to be here.
    I found a workaround for this problem here: http://www.sencha.com/forum/showthread.php?283059
    In short, one needs to populate filter's widget TextField with a value for that filter.