I have been using the FileterBuilder with great success and now would like to add an Auto Complete (ComboBoxItem?) feature on the value field. What is the best way to accomplish this?
Announcement
Collapse
No announcement yet.
X
-
Firstly, note that this is a technique that would only be applicable for certain combinations of field and operator. It isn't clear what level of history you're expecting to be made available to an auto-complete mechanism here, but note that the value field is often recreated as a result of fieldName or operator changing.
That said - if you want to make any changes to the value field in a FilterBuilder clause, you can do so by overriding FilterBuilder.getValueFieldProperties() - have it return a FormItem on which you've used setEditorType() or setEditorProperties() to assign a ComboBoxItem See the doc for those APIs..
-
I have done this as:
<CODE>
FilterBuilder filterBuilder = new FilterBuilder() {
public FormItem getValueFieldProperties(FieldType type, String fieldName, OperatorId operatorId, ValueItemType itemType, String fieldType) {
FieldDS options = FieldDS.getInstance(fieldName,objectType);
ComboBoxItem auto = new ComboBoxItem();
auto.setOptionDataSource(options);
auto.setDisplayField("name");
auto.setValueField("id");
auto.setShowPickerIcon(false);
auto.setFetchDelay(500);
auto.setLoadingDisplayValue(null);
//auto.setFilterLocally(false);
//auto.setTextMatchStyle(TextMatchStyle.EXACT);
auto.setShowOptionsFromDataSource(true);
Criteria criteria = new Criteria("field", fieldName);
criteria.addCriteria(new Criteria("objectType", objectType));
criteria.addCriteria(new Criteria("date", new Date().getTime()+""));
auto.setPickListCriteria(criteria);
//auto.setShouldSaveValue(false);
return auto;
}
};
</CODE>
This works for getting an auto complete on the value item. However, when getting the AdvancedCriteria from the filter builder with this set it always seems to return an OperatorId of iStartsWith instead of what is selected like iEquals or iContains, etc?
Comment
-
We've made a change to address this - as of builds dated October 8, getCriteria() will correctly return the operator and value pair as they appear in the FilterClause.
1) you might need to specifically setMultiple(false) on your ComboBoxItem properties if you see warnings in the Developer Console.
2) again, note that it only makes sense to install this mechanism for fields and operators of certain types
Comment
Comment