Page 1 of 1

Combo Box values depending on another Combox Box value selected

Posted: Mon Dec 16, 2019 8:07 pm
by stran
Hi,

I'd like to create two dropdown menus linked together. The values that you can select in the second dropdown menu would depend on the value you selected in the first dropdown menu.

Example:

I have combo box Vehicle Type and Combo Box Brand. If I select Car in the first combo box, the values in the second combo box will display the car brands. If you change to Airplane, the values in Combo Box Brand would change to the Ariplane brands.

Can I apply this with CSS/XML Schema?

Re: Combo Box values depending on another Combox Box value selected

Posted: Tue Dec 17, 2019 12:56 pm
by alex_jitianu
Hi,

It is possible. From a CSS you would do it by writing selectors for all possible combinations. Depending on the combinations, it can be a bit cumbersome. Let's assume that both combos edit attribute values:

Code: Select all


element:before(20) {
    content: oxy_combobox( 
            edit, '@vehicleType',
            editable, false,
            width, 20em,
            values, 'Car, Boat')
}

element[vehicleType='Car']:before(10) {
    content: oxy_combobox( 
            edit, '@brand',
            editable, false,
            width, 20em,
            values, 'VW, Renault')
}

element[vehicleType='Boat']:before(10) {
    content: oxy_combobox( 
            edit, '@brand',
            editable, false,
            width, 20em,
            values, 'BoatBrand1, BoatBrand2')
}

Perhaps a better approach would be to configure the content completion though a configuration file. In such a configuration file the values for an attribute can be computed through an XSLT which has access to the XML context. In the XSLT you can have a map from vehicleType to brands and it would be easier to compute the possible values. All it is left top do in the CSS is to bind the combo boxes, but leave the values to be taken from the schema/content completion customization:

Code: Select all

element:before(20) {
    content: "Vehicle type:" oxy_combobox( 
            edit, '@vehicleType',
            editable, false,
            width, 20em)
            " Brand:" oxy_combobox( 
            edit, '@brand',
            editable, false,
            width, 20em)
            
}
Please let me know if you need additional assistance.

Best regards,
Alex

Re: Combo Box values depending on another Combox Box value selected

Posted: Tue Dec 17, 2019 11:59 pm
by stran
Is there a way to use #text instead of attributes?

Re: Combo Box values depending on another Combox Box value selected

Posted: Wed Dec 18, 2019 3:24 pm
by Radu
Hi,

Something like this:

Code: Select all

<config xmlns="http://www.oxygenxml.com/ns/ccfilter/config">
    <match elementName="property">
        <xslt href="get_values.xsl" useCache="false" action="replace"/>
    </match>
</config>
should work to compute values for text content inside a certain element.
And you can use the oxy_combobox to also edit the text content of an element:

https://www.oxygenxml.com/doc/versions/ ... ditor.html

Regards,
Radu

Re: Combo Box values depending on another Combox Box value selected

Posted: Thu Dec 19, 2019 6:38 pm
by stran
Thank you!!!