I bind my ComboBox with a Option-DataSource, that have a more then one property.
How can i make multiple search/filtering in my ComboBoxItem?
thx.
How can i make multiple search/filtering in my ComboBoxItem?
thx.
ComboBoxItem item = new ComboBoxItem("myBox") { @Override protected Criteria getPickListFilterCriteria() { Criteria c = return super.getPickListFilterCriteria(); c.addAttribute("field2", item.getValue().toString()); c.addAttribute("field3", item.getValue().toString()); return c; } };
final DynamicForm form = new DynamicForm(); form.setWidth(300); ListGridField code = new ListGridField(PlStaatDTO.CODE); ListGridField staat = new ListGridField(PlStaatDTO.STAAT); PlStaatDS<PlStaatDTO> plStaatDS = new PlStaatDS<PlStaatDTO>(new PlStaatDTO()); final ComboBoxItem multipleSearchComboBox = new ComboBoxItem(PlStaatDTO.CODE) { @Override protected Criteria getPickListFilterCriteria() { Criteria c = super.getPickListFilterCriteria(); if (getValue() != null) { c.setAttribute(PlStaatDTO.CODE, getValue().toString()); c.setAttribute(PlStaatDTO.STAAT, getValue().toString()); } return c; } }; multipleSearchComboBox.setValueField(PlStaatDTO.CODE); multipleSearchComboBox.setWidth(240); multipleSearchComboBox.setPickListWidth(450); multipleSearchComboBox.setOptionDataSource(plStaatDS); multipleSearchComboBox.setPickListFields(code, staat); multipleSearchComboBox.setAutoFetchData(false); form.setItems(multipleSearchComboBox); form.draw();
public class PlStaatDS<T extends BaseDTO<T>> extends BaseDataSource2<T> { public PlStaatDS(T objektDTO) { super(objektDTO); init(); } private void init() { DataSourceTextField code = new DataSourceTextField(PlStaatDTO.CODE); code.setPrimaryKey(true); DataSourceTextField staat = new DataSourceTextField(PlStaatDTO.STAAT); setFields(code,staat); } }
final ComboBoxItem multipleSearchComboBox = new ComboBoxItem(PlStaatDTO.CODE) { @Override protected Criteria getPickListFilterCriteria() { AdvancedCriteria advancedCriteria1 = new AdvancedCriteria(PlStaatDTO.CODE,OperatorId.OR); AdvancedCriteria advancedCriteria2 = new AdvancedCriteria(PlStaatDTO.STAAT,OperatorId.OR); Criteria c = super.getPickListFilterCriteria(); if (getValue() != null) { c.addCriteria(advancedCriteria1); c.addCriteria(advancedCriteria2); } return c; } }; multipleSearchComboBox.setValueField(PlStaatDTO.CODE); multipleSearchComboBox.setWidth(240); multipleSearchComboBox.setPickListWidth(450); multipleSearchComboBox.setOptionDataSource(plStaatDS); multipleSearchComboBox.setPickListFields(code, staat); multipleSearchComboBox.setAutoFetchData(false);
Comment