Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

how to create a subform with several initialized rows?

Avatar

Former Community Member

I have a repeating subform in my form that should start with several initialized rows.

I can create several empty rows by setting the binding to "repeat subform for each data item" and setting the "min count", but I'd like to have values in one of the columns so this doesn't get me there.

I can create multiple instances of my named subform and initialize the value for the column in question, but then if I have the "repeat subform for each data item" checked I get additional dups of all but the first row and the delete button (with click action "this.parent.instanceManager.removeInstance(this.parent.index);") and add button (click action "_rates.addInstance(1)") behave erratically.  By this I mean the add button sometimes adds rows with values that have been deleted previously, and the delete button sometimes pops up an alert saying something like "topmostSubform[0]:Page1[0]:rates[10]:delete_button[0].click Index value is out of bounds".

There is no binding to a data source where I could pull the values for the column I wish to initialize.  I feel I'm close, if only I could find the correct settings for the binding palette.

Thanks for any suggestions!

1 Accepted Solution

Avatar

Correct answer by
Level 10

If you have Columns and Rows, why not use a Table instead of Subform..

Check the binding setting to "repeat Row for each data item".

Add the "Delete Row" button to each row in the last column.

Add the "Add Row" button below the Table.

Add Text Fields to the columns you want the data to be displayed/ modified by the user.

Hope this helps.

If not, let me know..

Thanks

Srini

View solution in original post

5 Replies

Avatar

Level 8

What values are you trying to put in the column?

Kyle

Avatar

Former Community Member

Some text values that the user is free to modify.

Avatar

Correct answer by
Level 10

If you have Columns and Rows, why not use a Table instead of Subform..

Check the binding setting to "repeat Row for each data item".

Add the "Delete Row" button to each row in the last column.

Add the "Add Row" button below the Table.

Add Text Fields to the columns you want the data to be displayed/ modified by the user.

Hope this helps.

If not, let me know..

Thanks

Srini

Avatar

Former Community Member

Thank you for the suggesting Srini.  I'm trying to implement but struggling with the scripting for the buttons and the binding settings.

I've tried the following for the click action for the delete buttons in each row:

     this.parent.instanceManager.removeInstance(this.parent.index);

and this for the click action for the add button under the table:

     rate_table._Row1.addInstance(true);

When I click on delete the javascript debugger pops up and tells me:

     GeneralError: Operation failed.

     XFAObject.removeInstance:1:XFA:topmostSubform[0]:Page1[0]:rate_table[0]:Row2[0]:delete_button[0]:click

     The element [min] has violated its allowable number of occurrences.

and when I click the add button the debugger tells me:

     General Error: Operation failed.

     XFAObject:addInstance:1:XFA:topmostSubform[0]:Page1[0]:#subform[16]:add_rates_button[0]:click

     The element [max] has violated its allowable number of occurences.

Sounds like my binding settings are wrong, but I haven't been able to determine a correct combination.  Can you assist?

Thanks in advance!

Avatar

Former Community Member

I teased out a set of binding settings that seem to work for me:

For the table check Repeat Table for Each Data Item and Initial Count and set the count to 1.

Select the table rows and in the binding tab set as described for the table.

Seems both of these are required, but I'm ready to believe there are other approaches that work.

Thanks again Srini!