PDA

View Full Version : [FNR] NumericFilter is broken when using remote filtering



thughes
17 Jan 2011, 3:25 AM
I have been looking at the following 2 grid examples in the GWT 2.2.1 Explorer.

http://www.sencha.com/examples/explorer.html#filtergrid

http://www.sencha.com/examples/explorer.html#remotefiltergrid

In the filter example, the numeric filter on the "Last" column works correctly. However, in the remote filter it does not. If you try a filter of "= 123.43" on both grids, in the filter example it correctly filters the grid to show just one row for "Apple Inc.", which is the only stock with this value. However in the remote filter grid, it shows all rows EXCEPT for the "Apple Inc." row, i.e. it does the exact opposite of what you would expect.

Also, when you try less than (<) filters or greater than (>) filters, these work correctly on the filter example, but work as <= or >= in the remote filter examples. If you try a filter of > 123.43, in the filter example it correctly shows just one row for "Google Inc." which has a value of 512.6, but in the remote filter it show this row as well as the "Apple Inc." row.

thughes
19 Jan 2011, 2:34 AM
It looks like the problem is in the validateModel() method in the NumericFilter class, see below. I think the operators should be == for 'rangemenu.eq', < for 'rangemenu.lt', and > for 'rangemenu.gt', however this method is using !=, <=, and >=. Can someone please confirm that this is the source of the error? I tried to override the NumericFilter class with one of my own to override this method, but am unable to do so as the fields have either private or package access only. Can anyone help with this please?




@Override
public boolean validateModel(ModelData model) {
Number val = getModelValue(model);
if (rangeMenu.eq != null && rangeMenu.eq.getValue() != null) {
if (val == null || rangeMenu.eq.getValue().doubleValue() != val.doubleValue()) {
return false;
}
}

if (rangeMenu.lt != null && rangeMenu.lt.getValue() != null) {
if (val == null || rangeMenu.lt.getValue().doubleValue() <= val.doubleValue()) {
return false;
}
}

if (rangeMenu.gt != null && rangeMenu.gt.getValue() != null) {
if (val == null || rangeMenu.gt.getValue().doubleValue() >= val.doubleValue()) {
return false;
}
}
return true;
}

sven
19 Jan 2011, 11:21 AM
For now you will need to overload the hole class. I will reply here once it is fixed in SVN

thughes
19 Jan 2011, 3:24 PM
OK, thanks for your reply. I Look forward to the fix!

sven
13 Sep 2011, 5:40 AM
Fixed in SVN as of revision 2435