I am using a ListGrid with a filter editor. In this filter editor I have a column that uses filter operators. As default operator it has LESS_OR_EQUAL, but also allows GREATER_OR_EQUAL and IBETWEEN_INCLUSIVE. On our website we offer the ability to save search criterias in the filter editor and then load them in. When trying to load a criteria that uses IBETWEEN_INCLUSIVE, the value does not display in the filter editor. This is because it is not set into the listGrid properly. How should I do to load the IBETWEEN_INCLUSIVE criteria into the filter editor/listgrid properly?
When running the following code:
where toSet is an AdvancedCriteria containing the values I hope to set; I get the following:
Clearly the data is in the AdvancedCriteria that is set, and the proper FilterOperator is also chosen, but for some reason it fails to load the value.
This is the function used to generate the first DataSource Instance to allow filter operators to work:
Settings related to filterEditor for table is as follows:
The column is set up as follows:
I use smartGWT version 6.0p with GWT version 2.8.1
When running the following code:
Code:
for (Criterion criterion : toSet.getCriteria()) { GWT.log(criterion.getFieldName() + ": " + criterion.getOperator() + ": " + criterion.getValueAsString()); } wcuTable.setFilterEditorCriteria(toSet); for (Criterion criterion : table.getFilterEditorCriteriaAsAdvancedCriteria().getCriteria()) { GWT.log(criterion.getFieldName() + ": " + criterion.getOperator() + ": " + criterion.getValueAsString()); }
Code:
wcuConnectionTime: IBETWEEN_INCLUSIVE: 772700...780711 *13:33:53.320:WARN:Log:Uncaught exception escaped: com.google.gwt.core.client.JavaScriptException (TypeError) : Cannot read property 'getCriteria_13_g$' of null at run_26_g$(FastePortal-0.js@131:367038) at fire_0_g$(FastePortal-0.js@8:26628) at anonymous(FastePortal-0.js@16:26585) at apply_40_g$(FastePortal-0.js@28:28576) at entry0_0_g$(FastePortal-0.js@16:28632) at anonymous(FastePortal-0.js@14:28612)
This is the function used to generate the first DataSource Instance to allow filter operators to work:
Code:
private DataSource getClientDataSourceWithFields() { DataSource ds = new DataSource(); int i = 0; ds.setClientOnly(true); DataSourceField[] dataSourceFields = new DataSourceField[VehiclesPanelColumn.values().length]; for ( VehiclesPanelColumn column : VehiclesPanelColumn.values()) { DataSourceField dataSourceField; if(column.equals(VehiclesPanelColumn.WCU_CONNECTION_TIME)) { // This is the column in question dataSourceField = new DataSourceField( column.getAttribute(), FieldType.INTEGER, column.getHeader()); dataSourceField.setValidOperators( OperatorId.GREATER_OR_EQUAL, OperatorId.LESS_OR_EQUAL, OperatorId.IBETWEEN_INCLUSIVE); } else { dataSourceField = new DataSourceField( column.getAttribute(), FieldType.ANY, column.getHeader()); dataSourceField.setValidOperators(OperatorId.REGEXP); } dataSourceFields[i++] = dataSourceField; } ds.setFields(dataSourceFields); return ds; }
Code:
table.setDataSource(getClientDataSourceWithFields()); table.setSaveLocally(true); table.setAllowFilterOperators(true); table.setDefaultFilterOperator(OperatorId.REGEXP);
Code:
ListGridField field = new ListGridField(column.getAttribute(), column.getHeader()); field.setType(ListGridFieldType.INTEGER); field.setAllowFilterOperators(true); field.setAlwaysShowOperatorIcon(true); field.setFilterOperator(OperatorId.LESS_OR_EQUAL); TextItem item = new TextItem(); item.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (event.getKeyName().toLowerCase().equals("enter")) { assembleQuestionAndGetResults(true); logStatistics("grid", StatisticsType.ENTER_PRESS); } } }); item.setHoverWidth(300); item.setItemHoverFormatter(new FormItemHoverFormatter() { @Override public String getHoverHTML(FormItem item, DynamicForm form) { String html = "<b>Less than or equal to</b><br>" + "Search for numbers less than or equal to the given number.<br>" + "<i>Example: '500'</i><br>" + "will search for those less than or equal to 500.<br>" + "<br>" + "<b>Greater than or equal to</b><br>" + "Search for numbers greater than or equal to the given number.<br>" + "<i>Example: '500'</i><br>" + "will search for those greater than or equal to 500.<br>" + "<br>" + "<b>Between (inclusive)</b><br>" + "Search for numbers between two numbers.<br>" + "<i>Example: '100...1000'</i><br>" + "will search between 100 and 1000, including 100 and 1000."; return html; } }); field.setFilterEditorProperties(item);
Comment