0

I need to create a comboBox control that displays a list of values but allowas the user to enter a value not in the list. I saw where you can do this with dijit.form.comboBox but I understand that no longer works after 8.5 something. So that route is out. This should be pretty basic and I'm guessing that I'm just missing a property somewhere. Any pointers?

Thanks in advance

Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
Bill F
  • 2,057
  • 3
  • 18
  • 39
  • Why should diji.form.comboBox not work? Maby you forgot Setting dojoForm="true" dojoTheme="true" dojoParseOnLoad="true" or to add the dojoModule Name="dijit.form.ComboBox" as resource to your XPage. – Michael Saiz Nov 29 '13 at 07:42

2 Answers2

2

Here is a working example for core control xp:comboBox where users can enter values not in list without using Extension Library:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view
    xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:this.resources>
        <xp:dojoModule
            name="dijit.form.ComboBox"
            rendered="true">
        </xp:dojoModule>
    </xp:this.resources>

    <xp:comboBox
        id="comboBox1"
        value="#{sessionScope.Test}"
        dojoType="dijit.form.ComboBox"
        disableValidators="true">
        <xp:selectItem itemLabel="abc"></xp:selectItem>
        <xp:selectItem itemLabel="def"></xp:selectItem>
        <xp:selectItem itemLabel="xyz"></xp:selectItem>
    </xp:comboBox>

    <xp:button
        value="Submit"
        id="button1">
        <xp:eventHandler
            event="onclick"
            submit="true"
            refreshMode="complete"
            immediate="false"
            save="true">
        </xp:eventHandler>
    </xp:button>
</xp:view>

Three things are important here:

  1. Add dojoModule ressource dijit.form.ComboBox
  2. Add dojoType="dijit.form.ComboBox"
  3. Add disableValidators="true" otherwise new values not in list won't get submitted.

If you are allowed to use Extension Library in your project then you would use Dojo Form control "Dojo Combo Box" xe:djComboBox of course instead.

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
  • In the end I did use the djComboBox and it is working fine, but I guess my N/D background keeps coming to the fore. I would think that this should be a property of a basic combo box just like in Note. "Allow Value Not in List" true/false. Yes, it is there in the djComboBox, and yes you can program around it, but.... Why? – Bill F Dec 03 '13 at 17:35
  • The reason for not being in standard is probably because it's not supported by standard HTML. HTML's ` – Knut Herrmann Dec 04 '13 at 20:17
  • This is exactly what I needed today, thank you @KnutHerrmann !!! (I see it now in the ext lib, duh. Its Friday afternoon here :) – Steve Zavocki May 15 '15 at 19:05
0

Got it with a djComboBox wish it were property of the core control.

Bill F
  • 2,057
  • 3
  • 18
  • 39