Join the Team Forms community

R
A
T
C
G

Applying an On Change from inside a Data Grid to the Row that it is triggered from

Last updated 8 hours ago

I am building a Data Grid that has multiple components on it and when the component labelled 'employees' is changed, I want the entire row to be updated to reflect different data that I have mapped from data sources.

Running the following line sets the entire Data Grid to the row that I wanted set,

Plain Text
      instance.root.getComponent('DataGrid').setValue(updatedRow) 

however I can't find a way to update just the row that the change is happening in.

A
1 comment
A
Anthony Phan

Hi Callum,

The easiest way to achieve this is by updating the row variable. For example, the steps below should work if using synchronous logic:

  1. Open the settings for the components/columns you will be updating and ensure you set the "redraw on" property to "any change". This step ensures the values you set in JavaScript are re-drawn and visible in the form.

  2. Open the settings for the component that will trigger the change (e.g. the employee) and add the following code to the On Change property. Note that you will need to adapt the code below to match your specific form and requirements.

JavaScript
const vehicle = instance.getValue() //Returns the value of the current component

row.brand = vehicle.brand
row.model = vehicle.model


Here is an example of the output: