Announcement

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

    Hiding combo box item pick list programmatically

    SmartClient Version: v8.3p_2013-02-13/LGPL Deployment (built 2013-02-13)
    Browser: Google Chrome 49.0.2623.112 m

    I have a combo box item which has showPickListOnKeypress set to true. I would like to hide the pick list when the pick list results arrive if the value entered in the item exactly matches the corresponding field in one of the returned records. That way, tabbing off of the combo box wouldn't automatically select the first pick list result, but rather it would use the exact value the user entered. I have tried the following, overriding ComboBoxItem.dataArrived:

    dataArrived: function(startRow, endRow, data) {
    if (data.containsProperty("ItemID", this.getValue())) {
    this.hidePicker();
    }
    }

    This implementation isn't hiding the pick list. I noticed that hidePicker() is a method on ComboBoxItem, but isn't documented. Is there a way either to hide the pick list programmatically or to conditionally prevent it from appearing?

    #2
    Tabbing away from a comboBox closes the combobox and uses a matching value if there is one, otherwise leaves the entered value alone. That seems to be what you're trying to achieve, but it's just the default behavior. So could you clarify what you want?

    Note that closing the picklist while the user still has focus in the field would be a bad idea - that would just look broken.

    Note, you are using a version well past end-of-life, so when checking on behaviors here, make sure you check the latest instead.

    Comment


      #3
      The problem is that the criteria field is not the same field that the combo box item corresponds to in our database table. We implement a search mechanism that allows the user to effectively search multiple record field values as they type into one field. We implement this by adding a field to, for example, our Item database table that is literally called "SearchField". For each Item record, it contains the space delimited values of other fields in that record, such as ItemID, ItemDescription, ProductCode, etc. So as the user types into the Item ID field, it searches for all Item records that contain the typed in text in either its ItemID, ItemDescription, ProductCode, and so on.

      The net is, the item records are not guaranteed to come back sorted by item ID. If multiple records match the search criteria, the first pick list record is selected by default. But if the customer happens to know the exact item ID that they want, such as "FAI", they want to type that in and tab off the field without it selecting the first pick list record, because that record may not be the one with ItemID "FAI".

      Comment


        #4
        Using comboBoxItem.filterFields would allow you to get rid of that hack, assuming you haven't done anything to prevent your server handling AdvancedCriteria.

        As far as the second behavior, we would say that's a questionable UE: if your itemIds overlap in value with the other searchable attributes of the records, users will sometimes expect the usual autocompletion behavior of a comboBox and be surprised when they happen to have typed in something that's an exact itemId. But if you want to go ahead with this, we'd recommend grabbing and holding onto the "data" argument in dataArrived, but not doing anything until editorExit, at which point you can check whether there's an exact match in the most recently returned search results and override the value that the ComboBoxItem will have chosen due to normal autoCompletion.

        Note even that strategy still has a hole if the exact match for itemId isn't in the first page of results returned by the comboBox. If that's a possibility you'd need to do a separate fetch against the comboBox's DataSource to determine if an exact match exists somewhere in the full dataset.

        Finally, note that there is a setting completeOnTab:false, which would completely turn off autoCompletion on tab, but that's probably also not what you want.

        Comment


          #5
          I'll look into that strategy. I may also look into dynamically changing completeOnTab in dataArrived using Class.setProperty(). Thanks for your help!

          Comment

          Working...
          X