Join the Team Forms community

Updated 4 days ago

Displaying the first row data in below rows

At a glance

The community member has a form with a data-grid (DG) component that contains number and text field components. They want the values entered in the first row of the DG to automatically populate the subsequent rows. A community member suggests setting the "Custom default value" setting of the text and number fields to a JavaScript expression that references the values from the first row, such as value = data.dataGridRepeatingTable[0].textField and value = data.dataGridRepeatingTable[0].number. Another community member confirms that this solution worked perfectly.

Hi everyone,

I have a form where I have a data-grid (DG) component inside and in that DG component I have a number and text field component , I want both of them to behave like if the user has written anything in those fields in the first row of the data-grid component I want the second row or any rows added of that same data-grid component to have the same values written in that number and text-field component.

Any suggestions would be helpful!
Thanks

Marked as solution

This can be achieved by setting the default value of the Textfield and Number fields within your data grid.

  1. Chance you data-grid to display a single row by default

  2. Open the component settings for the textfield within the data grid and navigate to the data tab. Set the "Custom default value" setting to a JavaScript expression to sets the value to the value of the textfield on the first row of the data grid.

    This is an example, however you will need to modify this to fit your specific form fields

Plain Text
value = data.dataGridRepeatingTable[0].textField
  1. Repeat the above for the number field. The JavaScript should be very similar e.g.

Plain Text
value = data.dataGridRepeatingTable[0].number


Here is an example of the final outcome:

View full solution
E
A
1 comment·1 reply

This can be achieved by setting the default value of the Textfield and Number fields within your data grid.

  1. Chance you data-grid to display a single row by default

  2. Open the component settings for the textfield within the data grid and navigate to the data tab. Set the "Custom default value" setting to a JavaScript expression to sets the value to the value of the textfield on the first row of the data grid.

    This is an example, however you will need to modify this to fit your specific form fields

Plain Text
value = data.dataGridRepeatingTable[0].textField
  1. Repeat the above for the number field. The JavaScript should be very similar e.g.

Plain Text
value = data.dataGridRepeatingTable[0].number


Here is an example of the final outcome:

Hi Erin,
Thank you for the guidance. It worked perfectly :)