I have an existing client form that contains a table of 50 rows and 5 columns - all with fields in them for the user to edit. I want to use a repeat control to display this data in the browser, instead of using a table with 250 fields in it.
Each of my fields are numbered according to their row, i.e. Num_1, Desc_1, Qty_1, Num_2, Desc_2, Qty_2, etc. where the columns are Num, Desc and Qty.
After searching online for hours, I was able to figure out that it’s just not that hard. In order to dynamically bind a control to a field in a repeat control, simply use js like this:
var indexstr = String(index+1); //repeat index must start at 0, removes the fraction
“#{document1.N_” + indexstr + “}”;
It must be computed on page load.
This data formula in an edit box control inside a repeat will dynamically bind each edit box to a different field in my form using the index of the repeat control. (note, my repeat index name is “index”)
Here’s the use case… I need to display a table - such as a checklist - for users to fill out. Typically, I would create a table of fields, multiple columns and sometimes up to 200 rows. Each field would be named with the row number, i.e. N_1, N_2, N_3 and so on. This becomes a maintenance nightmare as changes must be made to each field individually - especially the hide whens.
That’s why I hoped to find a better solution in xpages - and I have. Now, I have a simple repeat control with one row of controls that are dynamically bound to each corresponding field in my form.
BE CAREFUL! The selection to compute on page load will sometimes change to compute dynamically if you edit your control. Be sure to set it back to compute on page load, or it won’t work.
Subject: Can you do the same thing with checkboxes?
Hi,I’m trying to do a similar thing with checkboxes. I have a repeat control where I loop a dynamic array. In the repeat there is a checkbox so the page shows one checkbox for every object in the array. Then, when the form is submitted I want (on the server side) to read which checkboxes that were selected.
I tried to paste in “#{document1.N_” + indexstr + “}”; as data binding but all checkboxes ended up disabled/readonly.
Can anybody post more information about how to do this? I want to store the result in (session)scope instead of a document, does that make a difference?