Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ComboboxItem hilites drop-down records

    ComboboxItem hilites multiple records as shown in the attached screenshot.
    Can someone explain this behavior and how to control it.

    I'm trying to achieve custom behavior for comboboxitem:

    Code:
            DataSource supplyItemDS = DataSource.getDataSource("employees");
            final ComboBoxItem filteredSelect = new ComboBoxItem("filteredSelect");
    
            final ListGrid pickListProperties = new ListGrid();
            ListGridField name = new ListGridField("Name");
            ListGridField eId = new ListGridField("Email");
            pickListProperties.setDataPageSize(20);
            filteredSelect.setPickListBaseStyle("myBoxedGridCell");
            filteredSelect.setSortField(1);
            pickListProperties.addRecordClickHandler(new RecordClickHandler() {
                @Override
                public void onRecordClick(RecordClickEvent recordClickEvent) {
                    Record rec = recordClickEvent.getRecord();
                    String value = filteredSelect.getEnteredValue().contains(",") ? filteredSelect.getEnteredValue().substring(0, filteredSelect.getEnteredValue().lastIndexOf(",") + 1).trim() : "";
                    filteredSelect.setValue(value + rec.getAttribute("Name") +",");
    
                }
            });
    
            filteredSelect.setTitle("Item (Select)");
            filteredSelect.setOptionDataSource(supplyItemDS);
            filteredSelect.setDisplayField("Name");
            filteredSelect.setValueField("Email");
            filteredSelect.setPickListWidth(300);
            filteredSelect.setPickListFields(name, eId);
            filteredSelect.setPickListProperties(pickListProperties);
            filteredSelect.setShowPickerIcon(false);
            filteredSelect.setPickListFilterCriteriaFunction(new FormItemCriteriaFunction() {
                @Override
                public Criteria getCriteria(FormItemFunctionContext formItemFunctionContext) {
                    String searchText = filteredSelect.getEnteredValue();
                    String scz = searchText.contains(",") ? searchText.substring(searchText.lastIndexOf(",") + 1).trim() : searchText;
                    AdvancedCriteria criteria = new AdvancedCriteria(OperatorId.OR, new Criterion[]{
                            new Criterion("Name", OperatorId.ICONTAINS, scz),
                            new Criterion("Email", OperatorId.ICONTAINS, scz)
                    });
    
                    return criteria;  //To change body of implemented methods use File | Settings | File Templates.
                }
            });
    Also i need to show the data that starts with the text typed into the textitem and then the data that contains. Any ideas to achieve this.

    Thanks.
    Attached Files

    #2
    Your dataset may have colliding values for the primaryKey or the valueField set on the ComboBox.

    Comment

    Working...
    X