Check/Uncheck Checkbox Component UiPath Form

I found an article that can select all the ‘select boxes component’ in UiPath Form (link below), however, I am dealing with checkbox component in datagrid. Does anyone face the similar problem before? My rows are added dynamically based on the rows of datatable that I passed into the UiPath Form. Really appreciate your help.

You can follow the same blog post and use the below piece of code to check all the checkboxes inside a datagrid component instead of the code given in Step 5.

instance.emit('updateData', {});

//Uncheck if the first checkbox is checked
if(data.dataGrid[0].checkbox){
  data.dataGrid.forEach(item => {
    item.checkbox = false;
  });
}else{ // Check all checkboxes
  data.dataGrid.forEach(item => {
    item.checkbox = true;
  });
}

Note: dataGrid is the field key of the data grid component and checkbox is the field key of check box component.