Announcement

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

    Any way to have a filter editor on a SelectItem?

    I have a SelectItem with an optionDataSource specified and I'm using setPickListFields to show a grid with multiple columns in the dropdown. I'd like to also setShowFilterEditor on the pick list grid but there doesn't seem to be a way to do that. Am I missing just it or is that not possible?

    #2
    Use setPickListProperties to enable it with a call to setShowFilterEditor(true).

    Comment


      #3
      That was easy!

      Comment


        #4
        How can I access the underlying ListGrid for the PickList? For example, I'm not showing two columns in the PickList. One is an ID number and the other is a text field (name). If the user starts typing when the SelectItem has focus I want to showPicker() and then setFilterEditorCriteria() based on the character they just typed.

        SelectItem.addKeyPressHandler() let's me take control at the appropriate event, but I don't see any way to setFilterEditorCriteria() on the pick list grid.

        Comment


          #5
          This sounds like reinventing a ComboBox?

          Comment


            #6
            Sort of, but a ComboBox that shows two columns in the pick list and filters on one column or the other depending on the type of character typed. If I used a combo box how would I control how the typed value is used as filter criteria?

            Comment


              #7
              With an override of getPickListFilterCriteria().

              Comment


                #8
                Getting very close. The only added complication is that I want the displayed value, once a selection has been made, to include both the ID and the name. I'm using setEditorValueFormatter() to do that
                Code:
                hven.setEditorValueFormatter(new FormItemValueFormatter() {
                	@Override
                	public String formatValue(Object value, Record record,
                			DynamicForm form, FormItem item) {
                		Record selectedVendor = ((ComboBoxItem) item).getSelectedRecord();
                		if (selectedVendor==null)
                			return null;
                		else
                			return selectedVendor.getAttribute("VNAM")
                			+ " (" + selectedVendor.getAttribute("VVEN") + ")";
                	}
                });
                But that seems to be preventing me from changing the selection once it has been made. If type something into the field the pickList appears and is filtered correctly by the newly typed value, but then the value formatter replaces what I typed with the formatted value for the previous selection.

                Is there some way for the value formatter to be temporarily disabled while a new selection is being made?

                Comment


                  #9
                  I now realize this has nothing to do with my EditorValueFormatter. The same thing happens without it. If the user types something that results in a single row being selected the display field from that row is put into the combo box, overlaying whatever the user was typing. So there is no opportunity for them to change what they typed. They have to clear the combo box and start over. Is there some way to prevent that from happening so that once the pickList is shown the user has to actually pick an item from the list, even if there is only one item in the list? If there is only one item in the list and they tab out of the field that item should be selected.

                  Comment


                    #10
                    We do have plans to make that a switchable behavior, since it's inconvenient in some use cases. No ETA at the moment.

                    Comment


                      #11
                      Any workaround in the meantime? Something like autocomplete="off" would be great.

                      Comment

                      Working...
                      X