Page 1 of 1

Autocomplete and non-case sensitive Combobox

Posted: Tue Jan 21, 2020 11:27 pm
by stran
Hi,

I have a combobox linked to a configuration file for proposed values inside (editable=OnlyAllowedItems). https://www.oxygenxml.com/doc/versions/ ... in_context

Is there a way to have these dropdown menus autofill when you type manually or at least show in the dropdown the possible options (ex: If I type B, I wanna see the values that start with B etc.). And if I wanna type all manually, to not have these case sensitive?

Thanks

Re: Autocomplete and non-case sensitive Combobox

Posted: Thu Jan 23, 2020 1:40 pm
by alex_jitianu
Hi,

They should already work like that... When you start the editing session, for example by using the mouse, the popup with all the values is presented. As you type, the first value that matches is selected. Just press ENTER to commit the value. The combo is case insensitive, too.

Is this combo the one from the attributes panel or is it a form control?
I'm sorry if I didn't quite understand you situation... if that's the case , please give me more details.

Best regards,
Alex

Re: Autocomplete and non-case sensitive Combobox

Posted: Thu Jan 23, 2020 6:08 pm
by stran
Sorry if I wasn't clear. I'll go in with as much detail as possible.

So I have two combo boxes: primary and secondary. The values that you can select in Secondary depends on what is in Primary.

css:

Code: Select all

md\.primary:before {
    content:
    oxy_label(text, "Primary: ", width, 10%) 
        oxy_combobox( 
            edit, '#text', width, 20em);
    font-weight: bold;
}

md\.secondary:before {
    content:
    oxy_label(text, "Secondary: ", width, 10%) 
        oxy_combobox( 
            edit, '#text', width, 20em);
    font-weight: bold;
}
config xml file:

Code: Select all

<match elementName="md.primary" editable="onlyAllowedItems">
        <xslt href="getMetaCaijValues.xsl" useCache="false" action="replace"/>
    </match>

    <match elementName="md.secondary" editable="onlyAllowedItems">
        <xslt href="getMetaCaijValues.xsl" useCache="false" action="replace"/>
    </match>  
 

Code: Select all

<xsl:template name="getPrimaryValues">
        <items>
        	<item value="Prescription"/>
        </items>
  </xsl:template>
  
  <xsl:template name="getSecondaryValues">
        <xsl:variable name="linkedElement"
            select="saxon:eval(saxon:expression(concat($contextElementXPathExpression,'/../md.primary'), ./*))"/>
        <items>
        
        <xsl:if test="$linkedElement = 'Prescription'">
                <item value='Délais de prescription'/>
                <item value='Interruption et suspension de la prescription'/>
                <item value='Prescription acquisitive'/>
                <item value='Prescription extinctive'/>
                <item value='Renonciation à la prescrition'/>
            </xsl:if>
            </xsl:if>
        </items>
    </xsl:template>
When I write Prescription with case sensitivity in mind, it autofills and takes shows the values in Secondary, but if I type with a minuscule p:
https://imgur.com/a/XGq9o1y

Hopefully, this was more clear.

Re: Autocomplete and non-case sensitive Combobox

Posted: Tue Jan 28, 2020 11:20 am
by alex_jitianu
Hi,

I see... The lookup is case sensitive so when you start writing with a small "p" it will not match the upper case value. Because of that you will end up committing "prescription" which is not the proposed value. What you can do:
- if it doesn't really matter if the value is with a lower case or with an uper case, then you can change the XSLT to do a lower-case() and make decisions based on the value with all lower case.
- if the way the value is given matters and the user should choose from one of the proposed values, then why not make the combos not editable?

Code: Select all

md\.primary:before {
    content:
    oxy_label(text, "Primary: ", width, 10%) 
        oxy_combobox( 
            edit, '#text', width, 20em, editable, false);
    font-weight: bold;
}

md\.secondary:before {
    content:
    oxy_label(text, "Secondary: ", width, 10%) 
        oxy_combobox( 
            edit, '#text', width, 20em, editable, false);
    font-weight: bold;
}
Best regards,
Alex

Re: Autocomplete and non-case sensitive Combobox

Posted: Tue Jan 28, 2020 9:13 pm
by stran
Thanks!

I used the lower-case() method. Is there a way to make it so that it autofills even tho we type prescription with a lower-case p instead of a upper-case P?

Re: Autocomplete and non-case sensitive Combobox

Posted: Fri Jan 31, 2020 10:10 am
by alex_jitianu
Hi,

I don't think there's a way to configure this behavior. What if you put as possible values both forms, with lower case and with upper case? Not very elegant, but you'll get the end result you desire.

Best regards,
Alex

Re: Autocomplete and non-case sensitive Combobox

Posted: Fri Jan 31, 2020 6:03 pm
by stran
Thanks!