问题
ComboBoxItem buildings = new ComboBoxItem("buildings", "Building Names") {
public Criteria getPickListFilterCriteria() {
Criteria criteria = new Criteria();
criteria.setAttribute("dependentString", grid.getSelectedRecord().getAttribute("company"));
criteria.setAttribute("dependentString2", "office");
return criteria;
}
};
buildings.setOptionDataSource(CommonLookupDS.getLookupDS(LookupTypesClient.LOOKUP_BUILDINGS_BY_TYPE));
buildings.setValueField("key");
buildings.setDisplayField("value");
buildings.setWidth(125);
buildings.setWrapTitle(true);
buildings.setAutoFetchData(false);
buildings.setRequired(true);
Once the getPickListFilterCriteria method is overridden this comboBox stops filtering for user input. It shows all the options regardless of the user input. How to fix this?
回答1:
I put all my criteria settings to datasource and it works. So, in method transformRequest I do
public Object transformRequest(DSRequest dsRequest){
dsRequest.setHttpMethod("POST");
return "<json>";
}
回答2:
This can be done by appending criteria to datasource For an example
buildings.setOptionDataSource(CommonLookupDS.getLookupDS(LookupTypesClient.LOOKUP_BUILDINGS_BY_TYPE
+"&dependentString="+grid.getSelectedRecord().getAttribute("company")+"&dependentString2="+office));
and prevent from overriding getPickListFilterCriteria method
来源:https://stackoverflow.com/questions/37406929/smart-gwt-comboboxitem-deosnt-filter-based-on-user-input