Combo Box values depending on another Combox Box value selected

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

Combo Box values depending on another Combox Box value selected

Post by stran » Mon Dec 16, 2019 8:07 pm

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?

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

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

Post by alex_jitianu » Tue Dec 17, 2019 12:56 pm

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

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

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

Post by stran » Tue Dec 17, 2019 11:59 pm

Is there a way to use #text instead of attributes?

Radu
Posts: 7032
Joined: Fri Jul 09, 2004 5:18 pm

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

Post by Radu » Wed Dec 18, 2019 3:24 pm

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

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

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

Post by stran » Thu Dec 19, 2019 6:38 pm

Thank you!!!

Post Reply