Inserting an getting values at iteration grid

31 views
Skip to first unread message

Javier Echaniz

unread,
Oct 5, 2023, 2:47:38 PM10/5/23
to Orbeon Forms
Hi,

i'm trying to add selected values from a dropdown to an certain row in an iteration grid and then be able to select a certain row to get values from this row.

                <form>
                    <section-test>
                        <selectionDropdown/>
                        <row/>
                        <addData/>
                        <insertGrid>
                            <insertGrid-iteration>
                                <preferenceOrder/>
                                <data/>
                               <extractData/>
                            </insertGrid-iteration>
                        </insertGrid>
                        <dataExtracted/>
                    </section-test>
                </form>

I have a button (addData) that should insert the selected value from the dropdown to the iteration grid at the row typed in row field..

             <xf:action observer="addData-control" event="DOMActivate">             
                 <xf:insert  ref="//insertGrid" at="//row" position="after"/>     
                 <xf:setvalue ref="//data" value="//selectionDropdown"/>    
             </xf:action>  

With that action,  the value selected is inserted at first position and the rest of rows are overwritten with the value inserted the very first time, and i don't be able to solve it.

In the same example, i'm trying to pass the value from a row to a external field but i don't know how to get the index of a row to write the get function.

Could you give some idea?

Thanks in advance.

Javi.

Alessandro Vernet

unread,
Oct 9, 2023, 12:33:40 AM10/9/23
to orb...@googlegroups.com
Hi Javi,

Are you doing this by writing plain XForms, or is this done in the context of the form created with Form Builder? This looks like it might be Form Builder generated code based on the root `<form>` and the `-iteration` suffix. If so, you may want to do this using the action syntax (see link below). Would you be able to share the source of a minimal form with the drop-down and repeated grid? You could create the form on https://demo.orbeon.com/, save it, and paste the link in a reply here.


-Alex

--
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 orbeon+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/c876a071-cb76-4d06-a63f-a047c0acf600n%40googlegroups.com.

Javier Echaniz

unread,
Oct 9, 2023, 5:16:10 AM10/9/23
to Orbeon Forms
Hi Alex,

 thanks for the help. I've created an example as you said, 


In this example I have 3 buttons to insert rows. 
  - insertAtEnd -> Inserts a row at the end of the grid, but i'm not able to avoid inserting the first time when the first repetition is blank. I've tried to put conditions at action but it's like if they are not being evaluated.
  - insertAtRow2 -> Inserts a row in th second row and set its value (with the row number harcoded)
  - insertAtRow - In this button i've tried to insert a row in the row typed at row field, but i've only been able to make it run when i hardcode the number in the action. When i try to make reference to a field (//row, $row, row) it doesn't run. It only runs when i put a harcoded number or "end"

I have also a button to get the current index of a row but i don't know how to do it.

Thanks in advance.

Javi

Javier Echaniz

unread,
Oct 10, 2023, 4:05:41 AM10/10/23
to Orbeon Forms
Hi Alex,

 reading the documentation about "Adding repetitions to a repeat" (https://doc.orbeon.com/form-builder/advanced/services-and-actions/actions-syntax#adding-repetitions-to-a-repeat) i've noticed that values at attribute "at" it only can be " start, end, or a positive integer" and i don't know if it really means that the value can't be a variable value (such a field reference, //field, $field,...).

Thanks in advance.

 Javi

Alessandro Vernet

unread,
Oct 10, 2023, 7:08:00 PM10/10/23
to orb...@googlegroups.com
Hi Javier,

As you said, the `at` attribute is limited to `start', `end', or a positive integer, as mentioned in the documentation. For the first button, to avoid doing the insert if the last row is empty, there is no `if` attribute, but you should be able to use a `<fr:if condition="">`. I'll try to change your example to do that and then follow up here.

-Alex

Alessandro Vernet

unread,
Oct 12, 2023, 1:47:44 AM10/12/23
to orb...@googlegroups.com
Hi Javier,

The following code works, but needed a fix to be able to use the `last()` function in this case. Do you currently use Orbeon Forms PE? If so, we'll most likely have this fix in 2022.1.6.

    <fr:action name="actionAtEnd" version="2018.2">
        <fr:if condition="xxf:non-blank(fr:control-string-value('data')[last()])">
            <fr:repeat-add-iteration repeat="insertGrid" at="end"/>
        </fr:if>
        <fr:control-setvalue value="//dropdown" control="data" at="end"/>
    </fr:action>

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

-Alex

Alessandro Vernet

unread,
Oct 12, 2023, 4:26:21 PM10/12/23
to orb...@googlegroups.com
Hi Javi,

Ok, the following gets your around #6016, and is also arguably clearer:

    <fr:listener version="2018.2" events="activated" controls="insertAtEnd"
                 actions="actionAtEnd"/>            

    <fr:action name="actionAtEnd" version="2018.2">
        <fr:if condition="let $data := fr:control-string-value('data') return xxf:non-blank($data[last()])">

            <fr:repeat-add-iteration repeat="insertGrid" at="end"/>
        </fr:if>
        <fr:control-setvalue value="//dropdown" control="data" at="end"/>
    </fr:action>

Please let me know if this works for you.

-Alex

Alessandro Vernet

unread,
Oct 12, 2023, 10:27:53 PM10/12/23
to orb...@googlegroups.com
Javi, also #6016 is now fixed, and the fix would be in 2022.1.6.

-Alex

Echaniz

unread,
Oct 13, 2023, 3:00:45 AM10/13/23
to orb...@googlegroups.com
Hi Alex,

Thanks for the solution. It works for 2022 version. Unfortunately i have 2018 PE version and it doesn't works in this version and i can't (it is not allowed by my company) upgrade it.

Javi.



You received this message because you are subscribed to a topic in the Google Groups "Orbeon Forms" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orbeon/FteRlyPw80k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orbeon+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/CANrzKkmJoY8iHgvi60wXL-2d-XNZX7u3GYSksHtGDMdMmwbDmQ%40mail.gmail.com.

Alessandro Vernet

unread,
Oct 13, 2023, 12:31:30 PM10/13/23
to orb...@googlegroups.com
Hi Javi,

Understood, I can give it a shot on Orbeon Forms 2018.x. Are you on 2018.1 or 2018.2 (that year, we had 2 major releases, which is a bit unusual, hence my question)?

-Alex

Echaniz

unread,
Oct 13, 2023, 12:35:43 PM10/13/23
to orb...@googlegroups.com
Hi Alex, 

in my forms appears <created-with-version>2018.2.3.201905172253 PE</created-with-version>, so i suppose this is the version.

Thanks for your help.

Alessandro Vernet

unread,
Oct 14, 2023, 2:29:25 AM10/14/23
to orb...@googlegroups.com
Got it Javi, I'll try that on 2018.2 and follow up here.

-Alex

Alessandro Vernet

unread,
Oct 21, 2023, 1:29:13 AM10/21/23
to orb...@googlegroups.com
Hi Javi,

For reference, I've attached the source of the form I used to test this on 2018.2. Unfortunately, to insert a new row only if the value on the last row isn't empty, we need the `<fr:if condition="...">` construct, which is new in 2019.1 (see link below).

So I'm afraid you'll have to upgrade for this, and while you're at it, I'd recommend you upgrade to the latest stable release of 2022.1. I hope you'll be able to make this upgrade, and please let me know if you encounter any problems.

form.xml
Reply all
Reply to author
Forward
Message has been deleted
0 new messages