Autocomplete and non-case sensitive Combobox

Post here questions and problems related to oXygen frameworks/document types.
stran
Posts: 12
Joined: Mon Dec 16, 2019 6:51 pm

Autocomplete and non-case sensitive Combobox

Post by stran » Tue Jan 21, 2020 11:27 pm

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

alex_jitianu
Posts: 771
Joined: Wed Nov 16, 2005 11:11 am

Re: Autocomplete and non-case sensitive Combobox

Post by alex_jitianu » Thu Jan 23, 2020 1:40 pm

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

stran
Posts: 12
Joined: Mon Dec 16, 2019 6:51 pm

Re: Autocomplete and non-case sensitive Combobox

Post by stran » Thu Jan 23, 2020 6:08 pm

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.

alex_jitianu
Posts: 771
Joined: Wed Nov 16, 2005 11:11 am

Re: Autocomplete and non-case sensitive Combobox

Post by alex_jitianu » Tue Jan 28, 2020 11:20 am

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

stran
Posts: 12
Joined: Mon Dec 16, 2019 6:51 pm

Re: Autocomplete and non-case sensitive Combobox

Post by stran » Tue Jan 28, 2020 9:13 pm

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?

alex_jitianu
Posts: 771
Joined: Wed Nov 16, 2005 11:11 am

Re: Autocomplete and non-case sensitive Combobox

Post by alex_jitianu » Fri Jan 31, 2020 10:10 am

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

stran
Posts: 12
Joined: Mon Dec 16, 2019 6:51 pm

Re: Autocomplete and non-case sensitive Combobox

Post by stran » Fri Jan 31, 2020 6:03 pm

Thanks!

Post Reply