Default value in dynamic dropdown

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

Default value in dynamic dropdown

Bharamani
Hi all

        I have a Dynamic dropdown box(values are coming from services)
 
       In this case how to set default value?

Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

Alessandro  Vernet
Administrator
Hi Bharamani,

So I imagine you're using a service and action to populate the dropdown. How would the default be determined? Since you have a service producing the list of values, maybe you also want to have another service return the list of values?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

Bharamani
Yes I am using a service and action to populate the dropdown.

and i need to keep first value as a default .

how to do this?
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

Alessandro  Vernet
Administrator
Hi Bharamani,

So you're saying that you'd like to have the first item returned by the service selected by default, instead of having no value selected, which I imagine would be the first item of the list ("Please select:")?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

Bharamani
Yes Alex

       When you call service By default there is no value.

       consider service contain date1,date2,date3

       I want date1 as a default value.


       for all dropdown we are using databound file , which select default value as a "Please select".

       
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

Alessandro  Vernet
Administrator
Hi Bharamani,

Got it. Then, in the action, in addition to setting the "Selection Control Items", you can set the "Control Values". For instance, if your service returns a list of countries and you want to set the value of the control to be the one of the first country, you would do:

http://i.imgur.com/wkdXFCq.png

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

Bharamani
Hi Alex

 As i am using dynamic dropdown as shown below



please suggest if any solution.
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

Alessandro  Vernet
Administrator
Hi Bharamani,

I see, then, instead, I would recommend you use a "regular" Dropdown Menu, and populate both the "choices" showing in the dropdown and the initial value with an HTTP Service + an Action. You'll let me know if this makes sense for you.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

Bharamani
Hi Alex

 It works perfect with regular dropdown.
 (In case , If we want to use dynamic dropdown then any solution?)

 Thanks
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

Alessandro  Vernet
Administrator
Hi Bharamani,

I'm glad it worked. With a dynamic dropdown, you would still need to declare the HTTP Service + Action to populate it the dropdown value. You would skip the part of the action that populate the dropdown "choices", but your service would be called twice, once by the dynamic dropdown and once by the Server/Action, which doesn't make much sense. So I'd say that this is a case where you should really use a regular dropdown.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

Bharamani
Its ok

Thanks Alex
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

kotharv
In reply to this post by Alessandro Vernet
Hello Alex,

in the similar line I just need to set the dropdown to its first-option based on a radio button yes or on...could you guide me how can I achieve this.
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

Alessandro  Vernet
Administrator
Could you elaborate on the similarity? In general, setting the value of a dropdown based on the value on another field typically calls for using a calculation. Would that work in your situation?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

kotharv


based on image I need the option no need to admit to be set when no is choosen

I have written xpath something as below

if codepoint-equal(../dec-outcome()/text(), "yes")then  "/intention-readmit/item[1]/value/text()" else  " "

not working

<intention-readmit>
                            <label>Intention to Readmit: (if patient died-default to No plan to readmit)</label>
                            <hint/>
                            <help/>
                            <alert/>
                            <item>
                                <label>No plan to readmit within 28 days</label>
                                <value>no-plan-to-readmit-within-28 days</value>
                            </item>
                            <item>
                                <label>Readmit to other hosp within 28 days-booking arranged</label>
                                <value>readmit-to-other-hosp-within-28-days-booking-arranged</value>
                            </item>
                            <item>
                                <label>Readmit to other hosp within 28 days-no booking arranged</label>
                                <value>readmit-to-other-hosp-within-28-days-no-booking-arranged</value>
                               
               
               
               
            </item>
                            <item>
                                <label>Readmit to this hosp within 28 days-booking arranged</label>
                                <value>readmit-to-this-hosp-within-28-days-booking-arranged</value>
                            </item>
                            <item>
                                <label>Readmit to this hosp within 28 days-booking arranged</label>
                                <value>readmit-to-this-hosp-within-28-days-booking-arranged</value>
                            </item>
                        </intention-readmit>
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

kotharv
Hi Alex,
Could you analyse the Information or will you need any other information, let me know.
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

Alessandro  Vernet
Administrator
Assuming your Yes/No control in the top right of your screenshot is named `dec-outcome`, then for the dropdown, you can set:

- The Calculated Value expression to `if ($dec-outcome/string() = 'false') then 'no-plan' else .` assuming the value for the first option in the dropdown is `no-plan`.
- The Read-Only expression to `$dec-outcome/string() = 'false'`.

Also see this example that you can pasted in Form Builder and shows you this running. Is this inline with what you're trying to do?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

kotharv
thanks alex it's working
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

Alessandro  Vernet
Administrator
Great; I'm glad this worked for you, and thanks for the update.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

Nili
Hi Alex, I have an issue related to setting the initial value for a dynamic
drop down. I have a field that is User Cost Center (control name is
AWHCCENTRE) and I have a dynamic drop down list Site look up (please see
image)  <http://discuss.orbeon.com/file/t375728/1.jpg>  . Also see how the
drop down values are listing (please see image)
<http://discuss.orbeon.com/file/t375728/2.jpg>  Now I need to set the
default value of this based on the AWHCENTRE value.  For example if the
AWHCENTER is like below  <http://discuss.orbeon.com/file/t375728/3.jpg>  the
selected/initial value of the Site look up drop down needs to be the
corresponding one like this image
<http://discuss.orbeon.com/file/t375728/4.jpg>  Please help to resolve this
issue. Thanks.

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Default value in dynamic dropdown

Alessandro  Vernet
Administrator
For those finding this thread through a search, this question was
cross-posted on Stack Overflow. You can find the relevant link below. And
should you have any follow-up, feel free to use comments on Stack Overflow,
if appropriate.

https://stackoverflow.com/questions/54668331/setting-default-values-to-drop-down-in-orbeon-form-builder

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet