Default value in dynamic dropdown

classic Classic list List threaded Threaded
18 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