Dropdown issue

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

Dropdown issue

Bharamani
Hi ,

 How to set condition for dropdown value should selected once.

for example dropdown contain three values

i want to select first value once.


This is in repeating grid.
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Dropdown issue

Alessandro  Vernet
Administrator
Hi Bharamani,

What is the exact validation you want to hard? The first value must be selected exactly once? I.e. it is an error if never selected, and an error if selected more than once? Is this just with the first value, or all values? Is the list defined in the form, or loaded from a service?

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

Re: Dropdown issue

Bharamani
This post was updated on .
Hi Alex
 
        The list is defined in form only

        Scenario : value must be selected once?

        Is it possible by constrain?

        Example- Dropdown contain 3 values(sp,ch,dp)
 
                      sp and dp should be selected once if i select it for second time it should throw error.

        And when i select ch is it possible to calculate age using date control?
       
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Dropdown issue

Alessandro  Vernet
Administrator
Hi Bharamani,

Got it: so each value in the list must be selected exactly once. So I imagine that this means that you have exactly as many "lines" in your repeated grid as there are values in the dropdown.

So you have 2 possible "types" of errors:

1. A given value is selected more than once.
2. A given value is never selected.

For #1, it makes sense to show as invalid the 2 (or more) controls on which the user selected the same value. #2 is implied by #1: if you have n lines, n values, and the user selected a different value on each line, then all the values have been selected, so there is nothing more to check.

The validation will be on the control, and assuming the name of the control is my-control, it will look something like: for $current in . return count(../../*/my-control[. = $current]) = 1.

Does this make sense?

Alex
On Mon, Mar 28, 2016 at 10:39 PM Bharamani <[hidden email]> wrote:
Hi Alex

        The list is defined in form only

        Scenario : value must be selected once?(for all values)


-----
Regards
Bharamani
--
View this message in context: http://discuss.orbeon.com/Dropdown-issue-tp4661301p4661307.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.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].

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Dropdown issue

Bharamani
Hi Alex
 
      $current in . return count(../../*/my-control[. = $current]) = 1

     it works fine for all values

     But in case if i want to apply this for only one value
     what will be the expression
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Dropdown issue

Bharamani
Hi Alex


        Please give me the solution for this
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Dropdown issue

Alessandro  Vernet
Administrator
In reply to this post by Bharamani
Hi Bharamani,

What do you mean by "want to apply this for only one value"? You have a repeated grid, and want this validation to only apply to the control in the first iteration of the repeated grid?

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

Re: Dropdown issue

Bharamani
Hi Alex

 Example- Dropdown contain 3 values(sp,ch,dp)

        I want to apply this condition for only sp 

        for $current in . return count(../../*/relation[. = $current]) = 1


      I am trying not(../(preceding-sibling::*)/relation='sp')

      But it is refering to preceding iteration not  all



Scenario: dropdown contain 3 values.

              first value is selected once
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Dropdown issue

Alessandro  Vernet
Administrator
Hi Bharamani,

Got it, so one question is: which control do you mark as in invalid in the following situations:

- The user selected "sp" in multiple drop-downs. => You could mark those drop-downs as invalid.
- The user didn't select "sp" in any of the drop-down. => 1. You could mark all drop-downs as invalid. 2. Or you could create another control, say below the repeated grid, and mark that control as invalid.

Say you want to go with option 1, then the expression would look like:

for $count in count(../../*/relation[. = 'sp']) return $count = 1 or (. != 'sp' and $count > 1)

That is:

- If there is 1 'sp', we're good.
- If there is more than 1 'sp', we're good if this is not 'sp' (=> those with 'sp' will be marked as invalid).

I hope this helps, and that the logic makes sense so you can maybe infer what the XPath should be like in other similar situations,

Alex
On Mon, Apr 4, 2016 at 8:31 PM Bharamani <[hidden email]> wrote:
Hi Alex

 Example- Dropdown contain 3 values(sp,ch,dp)

        I want to apply this condition for only *sp*

      /  for $current in . return count(../../*/relation[. = $current]) = 1/


      I am trying /not(../(preceding-sibling::*)/relation='sp')/

      But it is refering to preceding iteration not  all



Scenario: dropdown contain 3 values.

              first value is selected once

-----
Regards
Bharamani
--
View this message in context: http://discuss.orbeon.com/Dropdown-issue-tp4661301p4661358.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.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].

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Dropdown issue

Bharamani
Thanks Alex

 This is good info.

 But one small change

 If i use
for $count in count(../../*/relation[. = 'sp']) return $count = 1 or (. != 'sp' and $count > 1)

Then user must select sp once.


In my case i am trying to avoid duplicate.

ie I want to implement only - The user selected "sp" in multiple drop-downs. => You could mark those drop-downs as invalid.

If user  did not select sp also no problem But he should not select twice(duplcate)


I hope this will make sense.
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Dropdown issue

Alessandro  Vernet
Administrator
Hi Bharamani,

If you just want to make sure users don't select 'sp' more than once, then the following should do the trick:

. != 'sp' or count(../../*/relation[. = 'sp']) = 1

That is: the current value is valid if it isn't "sp", or if the total count for "sp" is exactly 1.

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

Re: Dropdown issue

Bharamani
Thanks Alex

           It works fine.
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Dropdown issue

Alessandro  Vernet
Administrator
Bharamani, I'm glad it works, and thanks for confirming.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet