Need Help for remove action

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

Need Help for remove action

Bharamani
This post was updated on .
Hi i am using Repeating grid as shown in image





I want to remove only last two rows(Additional Insured #2) ,on click of remove button

I am using
                                    <xf:action ev:event="DOMActivate">
                                        <xf:delete ref=".."/>
                                    </xf:action>

it is removing complete .



Please help me to resolve this
Thanks
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Need Help for remove action

Alessandro  Vernet
Administrator
Hi Bharamani,

You seem to have placed all those controls in 1 iteration of a repeated grid. Instead, you should create 2 iterations, if you want users to have either 1 or 2, set the min to 1 and max to 2 in the grid properties.

Then users would use the provided mechanism to add/remove the additional insured persons. Does this make sense?

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

Re: Need Help for remove action

Bharamani
This post was updated on .
Thanks for reply

I removed Additional Insured #1 controls from iteration,
when i click add only second row is repeating .

But for first time as i shown in image,
Is it possible to hide remove button for first iteration

so that when i click add then only remove button should visible
(when grid count is one i need to hide remove button)

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

Re: Need Help for remove action

Alessandro  Vernet
Administrator
Hi Bharamani,

You should get this if you set the minimum number of iterations to 1 in the "Minimum Number of Repetitions":



Or am I misunderstanding 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: Need Help for remove action

Bharamani
This post was updated on .
Hi Alex

 if i set the minimum number of iterations to 1 in the "Minimum Number of Repetitions":

Then it will not add any row further

requirement is to add 10 additional insured but for first two insured i need to hide remove button as shown in first image

and also i need to hide add symbol for first two rows?
is it possible?
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Need Help for remove action

Alessandro  Vernet
Administrator
Hi Bharamani,

Mmmh… setting the minimum to 1 shouldn't prevent users from adding new iterations; just from removing the last iteration.

Could you show us what you are doing in Form Builder, and what it looks like at runtime, e.g. recording what you see with http://recordit.co/?

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

Re: Need Help for remove action

Bharamani
This post was updated on .
Hi Alex

Many thanks for reply

This is video............http://recordit.co/b2by0zYbfJ

add and remove is working fine .

but requirement is for first time as shown remove button should not visible
and for 1 person and 2 person add button should hide .
(There are two rows those are default , in that for first insured i did nt included remove link,
for second row  i added,this one i have to hide for first time
from third row it shoud be visible.)

In simple way , from second iteration remove link should be visible.

Does it make sense now.

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

Re: Need Help for remove action

Alessandro  Vernet
Administrator
Hi Bharamani,

Thank you for the video; I think this clarifies things a bit. Now, are you saying that:

- If "1 Person" is selected, then you want the repeated grid to be hidden.
- If "2 Persons" is selected, then you want the repeated grid to have 1 iteration, without the possibility to add/remove iterations.
- If "Family" is selected, then you want the repeated grid to start with 2 iterations, with the possibility to add iterations, but not go under 2 iterations.

Is that correct?

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

Re: Need Help for remove action

Bharamani
Yes Alex,

when 1 person  selected grid is hidden
when 2 person  one additional row is visible with no add button
when Family two additional row visible with remove button hidden and add button visible
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Need Help for remove action

Alessandro  Vernet
Administrator
Hi Bharamani,

Got it. At this point, just with the Form Builder UI, you can't add or remove iteration "programmatically". We have an RFE for this, linked below, and I have added a +1 from you.

https://github.com/orbeon/orbeon-forms/issues/1658

You could do this by adding some XForms to the source, but then this raises a number of questions. For instance, what happens with existing data users might have entered when they switch, say, from Family to 1 Person? Is the data just removed and lost?

Maybe it would be easier to not have the radio buttons, and just let users add family members as needed. That is, define the repeated grid with a minimum of 0 and no maximum.

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

Re: Need Help for remove action

Bharamani
Hi,

Is there any way to write Xpath Expression to hide any control in grid using min no of repetition or max no of repetition?

I mean when iteration is one or two then grid control is hidden.

Is it possible?
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Need Help for remove action

Alessandro  Vernet
Administrator
Hi Bharamani,

Yes: the min and max number of iterations can be XPath expressions, so they can be dynamic. As a result, controls to add/remove iterations will be hidden or be disabled accordingly. But the min/max changing won't remove or add iterations by itself.

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

Re: Need Help for remove action

Bharamani
Thanks Alex



I was asking about expression for hide one control.

for first two iteration i want to remove button ?

i used
          position() >2
          repeat-position> 2 for visibility

but no effect?

do u know any other way?
Thanks
Bharamani
Reply | Threaded
Open this post in threaded view
|

Re: Need Help for remove action

Alessandro  Vernet
Administrator
Hi Bharamani,

If your current grid is named "my-grid", to compute the current position, starting with 1, you could use:

count(../preceding::my-grid-iteration) + 1

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

Re: Need Help for remove action

Bharamani
Thanks Alex


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

Re: Need Help for remove action

Alessandro  Vernet
Administrator
Bharamani, thanks for confirming, and ideally, it would be nice if you could just use xxf:repeat-position() for this. I've created an issue for it:

https://github.com/orbeon/orbeon-forms/issues/2659

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

Re: Need Help for remove action

Bharamani
This post was updated on .
Alex

        In my scenario

        if i use xxf:repeat-position() > 2  for visibility its not working
     
         so i am using
         count(../preceding::my-grid-iteration) + 1 > 2

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

Re: Need Help for remove action

Alessandro  Vernet
Administrator
Bharamani, right, and ideally you'd just be able to use xxf:repeat-position(), but currently you can't, hence the issue.

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