[SmartClient Version: v11.0p_2016-10-01/PowerEdition Deployment (built 2016-10-01)] and [SmartClient Version: v10.0p_2016-02-18/PowerEdition Deployment (built 2016-02-18)]
NOTE: code snippets from the SmartGWT libraries are taken from v10.0p_2016-02-18/PowerEdition Deployment (built 2016-02-18)
The problem here is that after performing the initial server fetch of matching values to populate entries within a ComboBoxItem dropdown, client-side filtering performed when the filter is further refined (e.g. by typing more characters) is not stripping leading zeros when attempting to match numeric fields. Leading zeros on numeric fields (since they are not relevant) should be ignored when determining whether client-side refinement can be performed or a server-side fetch is required.
The problem can be seen by modifying the http://www.smartclient.com/#comboFilterRelated example as follows:
Now, type "012" quickly and you will see a number of values that start with "12" returned. This is because the server side has the following logic in SQLWhereClause.stringComparison() - specifically, lines 1387 and 1389 convert a numeric value supplied as a String to a BigDecimal or BigInteger. This, of course, means any leading zeros entered by the user are now no longer relevant:
However, instead of entering "012" quickly, now enter just "0" and allow the code to perform a server request to obtain values. No values are returned. Now type "12" and the client-side code will attempt to refine the previously returned result set (avoiding an additional server-side fetch). However, since there are no values to refine, still not values are displayed in the ComboBoxItem dropdown.
Compare this to the behavior if you instead first search for "012" (entered quickly so that the server request is initiated for values beginning with "12" and therefore values are returned) and then equally quickly delete "2" and type "3". A server request is initiated to fetch results beginning with "13". The client code clearly recognizes that this is not just a refinement. It seems to me that somewhere around where this determination is made, the code should check if it is searching on a numeric field and whether the previous filter value on which the result set is based evaluates to zero. If so, and if the new value evaluates to a non-zero value, then invoke a server request. Does that sound about right?
Thanks,
Gary O'Donnell
NOTE: code snippets from the SmartGWT libraries are taken from v10.0p_2016-02-18/PowerEdition Deployment (built 2016-02-18)
The problem here is that after performing the initial server fetch of matching values to populate entries within a ComboBoxItem dropdown, client-side filtering performed when the filter is further refined (e.g. by typing more characters) is not stripping leading zeros when attempting to match numeric fields. Leading zeros on numeric fields (since they are not relevant) should be ignored when determining whether client-side refinement can be performed or a server-side fetch is required.
The problem can be seen by modifying the http://www.smartclient.com/#comboFilterRelated example as follows:
Code:
isc.DynamicForm.create({ ID:"testForm", width: 550, numCols:4, fields : [ { name: "filteredCombo", title: "Item (ComboBox)", editorType: "ComboBoxItem", addUnknownValues:false, wrapTitle: false, optionDataSource: "supplyItem", displayField:"itemName", valueField:"SKU", filterFields:["itemID", "itemName"], pickListWidth:300, pickListFields:[ {name:"itemID"}, {name:"itemName"} ] } ] });
Code:
/* */ private String stringComparison(String fieldName, String columnType, String operator, Object objVal, boolean negate, SQLDriver driver, DSField field, BasicDataSource ds) /* */ throws Exception /* */ { /* 1366 */ if (fieldName == null) { /* 1367 */ log.error("Found a null fieldName"); /* 1368 */ return "('1'='1')"; /* */ } /* */ /* */ /* */ /* */ /* 1374 */ if ((driver.castNumbersBeforeLikeCompare()) && ( /* 1375 */ (ds.simpleTypeInheritsFrom(columnType, "integer")) || (ds.simpleTypeInheritsFrom(columnType, "float")))) /* */ { /* 1377 */ fieldName = "CAST(" + fieldName + " AS varchar(50))"; /* */ } /* */ /* 1380 */ if (((ds.simpleTypeInheritsFrom(columnType, "integer")) || (ds.simpleTypeInheritsFrom(columnType, "float"))) && (objVal != null)) { /* */ try /* */ { /* 1383 */ if ((objVal instanceof Date)) { /* 1384 */ objVal = new Long(((Date)objVal).getTime()).toString(); /* */ } /* 1386 */ else if (ds.simpleTypeInheritsFrom(columnType, "float")) { /* 1387 */ objVal = new BigDecimal(objVal.toString()).toString(); /* */ } else { /* 1389 */ objVal = new BigInteger(objVal.toString()).toString(); /* */ } /* */ } /* */ catch (Exception e) { /* 1393 */ log.warn("Got non-numeric value '" + objVal + "' for numeric column '" + fieldName + "', creating literal false expression: " + e); /* */ /* */ /* */ /* */ /* 1398 */ if (negate) { /* 1399 */ return "('1'='1')"; /* */ } /* 1401 */ return "'0'='1'"; /* */ } /* */ }
Compare this to the behavior if you instead first search for "012" (entered quickly so that the server request is initiated for values beginning with "12" and therefore values are returned) and then equally quickly delete "2" and type "3". A server request is initiated to fetch results beginning with "13". The client code clearly recognizes that this is not just a refinement. It seems to me that somewhere around where this determination is made, the code should check if it is searching on a numeric field and whether the previous filter value on which the result set is based evaluates to zero. If so, and if the new value evaluates to a non-zero value, then invoke a server request. Does that sound about right?
Thanks,
Gary O'Donnell
Comment