In this thread I' m going to provide 2 standalones for two bug realted to grid filtering.
BUG 1) Even though this has already been discussed and I have been told that the fix is applied in build 28.07.2015 and later, there is no such. (http://forums.smartclient.com/showpost.php?p=133181&postcount=18)
I am using build SmartClient Version: v10.0p_2015-07-30/LGPL Development Only (built 2015-07-30)
Steps to reproduce:
1) Open the date filter
2) Select as start date: today
3) Fitler
In result you should see that the criteria is pretty messed up:
13:08:28.112:TMR5:WARN:Log:event.getCriteria(): {operator=and, _constructor=AdvancedCriteria, criteria=[{fieldName=f2, operator=greaterOrEqual, value=Fri Jul 31 12:00:00 GMT+300 2015}, {operator=iContains, fieldName=fieldName, value=f1}, {operator=iContains, fieldName=operator, value=equals}, {operator=equals, fieldName=value, value=1}]}
BUG 2) When I have a grid criteria coming from different components and on FilterEditorSubmitEvent I would like to cancel the filtering, collect the entered filters and fetch using the newly created criteria (adding the filters ofc).
Here is the code:
In result if you filter Field 2 with a value 'a' you will get:
13:27:43.266:KPR7:WARN:Log:event.getCriteria(): {fieldName=f1, operator=equals, value=1, f2=a}
13:27:43.267:KPR7:WARN:Log:getFilterEditorCriteria: {fieldName=f1, operator=equals, value=1, f2=a}
13:27:43.269:KPR7:WARN:Log:asAdvancedCriteria: {_constructor=AdvancedCriteria, operator=and, criteria=[{fieldName=fieldName, operator=iContains, value=f1}, {fieldName=operator, operator=iContains, value=equals}, {fieldName=value, operator=equals, value=1}, {fieldName=f2, operator=iContains, value=a}]}
As you can see the asAdvancedCriteria() is messing up the criteria.
Just FYI both bugs ARE NOT in build SmartClient Version: v10.0p_2015-07-07/LGPL Development Only (built 2015-07-07).
BUG 1) Even though this has already been discussed and I have been told that the fix is applied in build 28.07.2015 and later, there is no such. (http://forums.smartclient.com/showpost.php?p=133181&postcount=18)
I am using build SmartClient Version: v10.0p_2015-07-30/LGPL Development Only (built 2015-07-30)
Code:
@Override
public void onModuleLoad() {
final ListGrid grid = new ListGrid();
grid.setShowFilterEditor(true);
grid.setWidth100();
grid.setHeight100();
grid.addFilterEditorSubmitHandler(new FilterEditorSubmitHandler() {
@Override
public void onFilterEditorSubmit(FilterEditorSubmitEvent event) {
SC.logWarn("event.getCriteria(): " + event.getCriteria().getValues());
}
});
DataSourceTextField f1 = new DataSourceTextField("f1", "Field 1");
f1.setCanFilter(true);
DataSourceDateField f2 = new DataSourceDateField("f2", "Field 2");
f2.setCanFilter(true);
DataSource datasource = new DataSource();
datasource.setClientOnly(true);
datasource.setFields(f1, f2);
grid.setDataSource(datasource);
grid.fetchData(new AdvancedCriteria(OperatorId.AND, new Criterion[]{new Criterion("f1", OperatorId.EQUALS, 1)}));
grid.draw();
}
1) Open the date filter
2) Select as start date: today
3) Fitler
In result you should see that the criteria is pretty messed up:
13:08:28.112:TMR5:WARN:Log:event.getCriteria(): {operator=and, _constructor=AdvancedCriteria, criteria=[{fieldName=f2, operator=greaterOrEqual, value=Fri Jul 31 12:00:00 GMT+300 2015}, {operator=iContains, fieldName=fieldName, value=f1}, {operator=iContains, fieldName=operator, value=equals}, {operator=equals, fieldName=value, value=1}]}
BUG 2) When I have a grid criteria coming from different components and on FilterEditorSubmitEvent I would like to cancel the filtering, collect the entered filters and fetch using the newly created criteria (adding the filters ofc).
Here is the code:
Code:
@Override
public void onModuleLoad() {
final ListGrid grid = new ListGrid();
grid.setShowFilterEditor(true);
grid.setWidth100();
grid.setHeight100();
grid.addFilterEditorSubmitHandler(new FilterEditorSubmitHandler() {
@Override
public void onFilterEditorSubmit(FilterEditorSubmitEvent event) {
event.cancel();
SC.logWarn("event.getCriteria(): " + event.getCriteria().getValues());
SC.logWarn("getFilterEditorCriteria: " + grid.getFilterEditorCriteria().getValues());
AdvancedCriteria criteria = grid.getFilterEditorCriteria().asAdvancedCriteria();
SC.logWarn("asAdvancedCriteria: " + criteria.getValues());
criteria.addCriteria(getMainCriteria());
grid.fetchData(criteria);
}
});
DataSourceTextField f1 = new DataSourceTextField("f1", "Field 1");
f1.setCanFilter(true);
DataSourceTextField f2 = new DataSourceTextField("f2", "Field 2");
f2.setCanFilter(true);
DataSource datasource = new DataSource();
datasource.setClientOnly(true);
datasource.setFields(f1, f2);
grid.setDataSource(datasource);
grid.fetchData(getMainCriteria());
grid.draw();
}
private AdvancedCriteria getMainCriteria() {
return new AdvancedCriteria(OperatorId.AND, new Criterion[]{new Criterion("f1", OperatorId.EQUALS, 1)});
}
13:27:43.266:KPR7:WARN:Log:event.getCriteria(): {fieldName=f1, operator=equals, value=1, f2=a}
13:27:43.267:KPR7:WARN:Log:getFilterEditorCriteria: {fieldName=f1, operator=equals, value=1, f2=a}
13:27:43.269:KPR7:WARN:Log:asAdvancedCriteria: {_constructor=AdvancedCriteria, operator=and, criteria=[{fieldName=fieldName, operator=iContains, value=f1}, {fieldName=operator, operator=iContains, value=equals}, {fieldName=value, operator=equals, value=1}, {fieldName=f2, operator=iContains, value=a}]}
As you can see the asAdvancedCriteria() is messing up the criteria.
Just FYI both bugs ARE NOT in build SmartClient Version: v10.0p_2015-07-07/LGPL Development Only (built 2015-07-07).
Comment