If you’d like to provide users the ability to type directly into an XPages combo box (like Dialog List field in the Notes client), you can easily convert combo boxes to dojo filtering select controls in XPages.
Combo Box
Let’s start with this straightforward combo box:
<xp:comboBox id="comboBox1"> <xp:selectItem itemLabel="Acai"></xp:selectItem> <xp:selectItem itemLabel="Apple"></xp:selectItem> <xp:selectItem itemLabel="Apricot"></xp:selectItem> <xp:selectItem itemLabel="Artichoke"></xp:selectItem> <xp:selectItem itemLabel="Asparagus"></xp:selectItem> <xp:selectItem itemLabel="Avocado"></xp:selectItem> </xp:comboBox>
Dojo Filtering Select
If you have the extension library, 8.5.3 with Upgrade Pack 1, or Notes 9, the Dojo Filtering Select control is available to you in the Dojo Form section of the Controls palette. When you drag it onto a page, it looks the same as the standard Combo Box on the Design tab.
The primary difference between the two is that you can type directly into the filtering select in order to narrow down the choices.
Easily Creating a Dojo Filtering Select
There’s also a major difference in Domino Designer when creating a filtering select — it doesn’t have the ‘Values’ subtab in its properties, so there isn’t a similar method of building the options for the list.
There are two simple ways to convert this to a dojo filtering select.
1) Manually change the xp:comboBox tag to xe:dojoFilteringSelect (along with the corresponding closing tag)
2) Drag a Dojo Filtering Select control onto the page and copy all of the xp:selectItem tags into it (then remove the combo box)
In fact, this is the best way that I know of to create a dojo filtering select easily. They can be enhanced to work with a different data store, but if your list of options is hard-coded or computed with SSJS, this is an easy way to go.
<xe:djFilteringSelect id="djFilteringSelect1"> <xp:selectItem itemLabel="Acai"></xp:selectItem> <xp:selectItem itemLabel="Apple"></xp:selectItem> <xp:selectItem itemLabel="Apricot"></xp:selectItem> <xp:selectItem itemLabel="Artichoke"></xp:selectItem> <xp:selectItem itemLabel="Asparagus"></xp:selectItem> <xp:selectItem itemLabel="Avocado"></xp:selectItem> </xe:djFilteringSelect>
UI Features
Even though it’s a combo box at its core, the filtering select control functions quite differently than the standard combo box.
1) The UI is a little different, as the filtering select picks up dojo styling. This is definitely something to keep in mind; you may need to add CSS to restyle it to keep it consistent with the rest of the page.
2) As you start typing, it will filter the list to only include the values that start with the characters that have been typed.
3) If the user types a value that is not valid in the list, an icon displays in the field and an error message pops up next to the field.
When this happens, no server-side code will execute, because it’s failing client-side validation that’s built into the control.
