-
14 Jan 2013 12:37 AM #1
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?
-
15 Jan 2013 10:03 PM #2
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.
-
16 Jan 2013 3:10 AM #3
thanks for replying Colin.
I'm certain that it is gxt 3.0
-
16 Jan 2013 11:30 AM #4
There is no StringFilter.setValue call in GXT 3.
To add a filter to a GXT 3 store, you'll do something like this:
You can build any implementation of StoreFilter that you want to be able to run specific queries.Code:store.addFilter(new StoreFilter<Film>() { public boolean select(Store<Film> store, Film parent, Film item) { return item.getDescription().contains("do"); } }); store.setEnableFilters(true);
-
24 Jan 2013 9:56 PM #5
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.
-
28 Jan 2013 4:51 PM #6
I'm not sure I understand exactly what you are asking - what is the unpredictable behavior you are worried about?
-
13 Feb 2013 6:10 PM #7
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 doingand 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)someStringFilter.setValue((String) aFilterWord)
in GXT3 i doand 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 properlyInfo.display("Debug",someStringFilter.getFilterConfig().get(0).getValue());
in GXT3 if i donothing happens, not evensomeStringFilter.getFilterConfig().get(0).setValue((String) aFilterWord)does not display the content of aFilterWord and in the UI if i look at the grid header filter is nothing in there.Info.display("Debug",someStringFilter.getFilterConfig().get(0).getValue());
-
28 Feb 2013 10:32 AM #8
anyoane any idea if someStringFilter.getFilterConfig().get(0).setValue((String) aFilterWord) is broken or i'm missuing it ?


Reply With Quote