Announcement

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

  • Trouble with ComboBoxItem

    I need textbox with autocomplete and find on this forum that ComboBoxItem is suitable for this task. But I can't solve one issue with this widget. When pickerList is shown always first element is selected, but i need all rows unselected. I need this behaviour because if no selected item and user push "Enter" search should been started.

  • #2
    I ran into the exact same problem.

    Our use case.

    - We use ComboBoxItem with setOptionDataSource() to show suggestions when a user types a search phrase.
    - When a user types "te", e.g., options such as "test", "taste", "tease", etc show up. This is working as expected.
    - However, if none of the options is what the user wanted, and the user hits Enter on the keyboard (thinking it would search for "te"), the SmartGWT code replaces "te" with the first option "test".

    I'm wondering if there's a way to override this default behavior, i.e. not automatically chooses the first option, or let us add a handler to decide what to do with "Enter".

    Comment


    • #3
      Actually, the previous poster's problem is unrelated - he wants to search on Enter keypress.

      Both problems can be solved by adding a keypress handler and cancelling when Enter is pressed. However, in both cases, you would be violating the user's expectation of how a comboBox normally works, and your app would probably fail an accessibility review for this reason as well.

      Note that simply tabbing out of the field is a way for the user to keep whatever value he entered, and as that's the standard interaction, we'd recommend just leaving it that way.

      Comment


      • #4
        I just tried using KeyPressHandler, the first "Enter" still replaces "te" with the first option in the dropdown, i.e. "test". Only the second "Enter" goes into KeyPressHandler. By then, I would be searching for "test", not "te".

        In the previous post, he wanted to search on Enter keypress without the first selected (I thought he meant replaced).

        Comment


        • #5
          Ah, sorry, keyPress handler is too late. This could only be done by a keyDown handler. But again, as we explained above, this does not seem like something you want to do anyway.

          Comment


          • #6
            KeyDownHandler seems to work differently than KeyPressHandler.

            However, it still changes "te" to "test" and submits a search. I only wanted it to submit a search without changing from "te" to "test". When user types "te", there are suggestions, but user wants to hit "Enter" and not want the search phrase to be changed, unless explicitly clicking on one of the suggested phrases.

            Comment


            • #7
              Hi dag_support
              The default Enter keypress behavior for ComboBoxItem is actually determined by the component it is embedded in.
              If embedded in a standard DynamicForm, the selected entry in the pickList will always be chosen on enter keypress. If embedded in a filtering interface (a SearchForm, or the filterEditor of a ListGrid), the selected entry is not chosen by default.
              So you can probably get the behavior you want by putting your item in a SearchForm instance rather than a DynamicForm instance.

              We also realize that it would be helpful to have a way to explicitly control this so we will be adding a property "completeOnEnter" to do this. For now we plan to add this to the development branch (12.1d) only.

              Please let us know if this doesn't give you enough information to get things working

              Regards
              Isomorphic Software

              Comment

              Working...
              X