Hi Smart GWT,
My Smart GWT version is: SC_SNAPSHOT-2011-08-02/PowerEdition Deployment (built 2011-08-02) and browser is Firefox 22.0
I need you to clarify me how grid filter works and to suggest me what is the best way to do something.
I have a grid that in code looks like this:
Basically, it is the grid from your Showcase application, example Grids/Filtering/Live filter. I made one change to the code from your example. I added AdvancedCriteria to the grid. As you can see, grid is based on data source, it has filter editor enabled and it has criteria to filter the data.
When user enters some value in any filter editor field during runtime, then data in the grid are filtered by combining newly entered criteria and criteria which has been set on grid in code. That is how grid filter should work and I get such behaviour.
Now, I have need to set filter editors values from code. For example, I have added button on interface and I need to set specific values in filter editor when user clicks that button. Also, I want to filter grid by combining two criteria, one entered in click handler and one initially set on grid. Button and its click handler look like this:
Unfotunately if I set filter criteria like this, then criteria which is initially added is completely ignored. Data are filtered only by criteria added in click handler and not by combining two of them, which I have expected.
Is that regular behaviour or it is a bug?
How can I set filter editor values from code and get data which are filtered by both criteria?
My Smart GWT version is: SC_SNAPSHOT-2011-08-02/PowerEdition Deployment (built 2011-08-02) and browser is Firefox 22.0
I need you to clarify me how grid filter works and to suggest me what is the best way to do something.
I have a grid that in code looks like this:
Code:
final ListGrid countryGrid = new ListGrid(); countryGrid.setShowFilterEditor(true); countryGrid.setFilterOnKeypress(true); countryGrid.setDataSource(WorldXmlDS.getInstance()); countryGrid.setAutoFetchData(true); ListGridField countryCodeField = new ListGridField("countryCode", "Code", 50); ListGridField nameField = new ListGridField("countryName", "Country"); ListGridField capitalField = new ListGridField("capital", "Capital"); ListGridField continentField = new ListGridField("continent", "Continent"); countryGrid.setFields(countryCodeField, nameField, capitalField, continentField); // Add criteria AdvancedCriteria criteria = new AdvancedCriteria(OperatorId.AND, new Criterion[] {}); Criterion c1 = new Criterion("continent", OperatorId.EQUALS, "Europe"); criteria.addCriteria(c1); countryGrid.setCriteria(criteria);
When user enters some value in any filter editor field during runtime, then data in the grid are filtered by combining newly entered criteria and criteria which has been set on grid in code. That is how grid filter should work and I get such behaviour.
Now, I have need to set filter editors values from code. For example, I have added button on interface and I need to set specific values in filter editor when user clicks that button. Also, I want to filter grid by combining two criteria, one entered in click handler and one initially set on grid. Button and its click handler look like this:
Code:
Button testBtn = new Button("Set filter"); testBtn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Criteria criteria = new Criteria("countryName", "Israel"); setFilterEditorCriteria(criteria); countryGrid.filterByEditor(); } });
Is that regular behaviour or it is a bug?
How can I set filter editor values from code and get data which are filtered by both criteria?
Comment