Setting component values via client script in UI Builder

Casper6060
Mega Sage

in UI Builder, i have a page where i have a grid of checkboxes, the columns are statis, but the rows are dynamically generated via a repeater with a local data source.

 

Does anyone know if it's possible to change the checkboxes states via client script code?

I dont think i can use states since states cant be created dynamically.

 

The idea is that outside of the repeater i have a header row of checkboxes, if you put a checkbox into one of the header columns, all checkboxes in that column would be checked automatically.

Is it possible to use scripting to se values on the form?

1 ACCEPTED SOLUTION

Casper6060
Mega Sage

So i looked into this and i cant see that this is possible (at least normally) instead I found the best way to handle this, was to make sure each checkbox had a checked event mapping on them. Then when the checkbox was checked i would add information like name, value and other required information to a state a made called checkboxHandler, and if the checkbox was unchecked (event payload value was false) then i looked up the data in my checkboxHandler state and if a value was found, i removed it from the array.

This was perfect for each individual checkbox, but i also had header checkboxes for each category, and then i also had a main header checkbox for each column.

Here it was the same concept, i just had to iterate through each row and set the value in the checkboxHandler array or remove them, depending on the payload value.

View solution in original post

1 REPLY 1

Casper6060
Mega Sage

So i looked into this and i cant see that this is possible (at least normally) instead I found the best way to handle this, was to make sure each checkbox had a checked event mapping on them. Then when the checkbox was checked i would add information like name, value and other required information to a state a made called checkboxHandler, and if the checkbox was unchecked (event payload value was false) then i looked up the data in my checkboxHandler state and if a value was found, i removed it from the array.

This was perfect for each individual checkbox, but i also had header checkboxes for each category, and then i also had a main header checkbox for each column.

Here it was the same concept, i just had to iterate through each row and set the value in the checkboxHandler array or remove them, depending on the payload value.