orbeon / orbeon-forms

Orbeon Forms is an open source web forms solution. It includes an XForms engine, the Form Builder web-based form editor, and the Form Runner runtime.
http://www.orbeon.com/
GNU Lesser General Public License v2.1
514 stars 220 forks source link

Way to know the current repeat iteration position #4144

Open ebruchez opened 5 years ago

ebruchez commented 5 years ago

From within a repeated grid or section, you would think you could use xxf:repeat-position(), but it doesn't work. Ideally, we'd like a Form Runner function anyway. Suggestions:

Workarounds (repeated section, 2019.1 repeated grid):

count(../preceding-sibling::*) + 1

Workarounds (2018.2 and earlier repeated grid):

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

+1 from customer

ebruchez commented 5 years ago

See also #3189 which calls for a built-in feature to show a row number.

avernet commented 4 years ago

+1 from user

avernet commented 3 years ago

+1 from customer

ebruchez commented 3 years ago

For nested repetitions:

ebruchez commented 2 years ago

The reason xxf:repeat-position() doesn't work is that it is evaluated in the model, where there are no <xf:repeat>.

ebruchez commented 2 years ago

This must work in formulas as well, in particular with relevant, readonly, and calculate.

ebruchez commented 2 years ago

We have BindingContext.position. This is used xxf:repeat-position(), but there is also logic that identifies explicitly repeat ancestors to find the binding whose position must be read. In the model, everything is a bind, so how can we do the same? With Form Runner, we have by default foo-iteration as name, but if the form author picks a custom iteration name, then we don't have the -iteration suffix.

avernet commented 2 years ago

+1 from customer

MatousAc commented 1 year ago

Was this ever resolved? Or do I still have to use the janky workaround? I can't get xff:repeat-position() to work.

ebruchez commented 1 year ago

@MatousAc I don't think it's been addressed yet. Let's try to get this fixed in a release soon.