I have an array of data, and I want to create multiple rows of checkboxes for these values. So let's say I have 30 values and i want 10 checkboxes per row. So that would give me three rows of checkboxes. I did something like this to create it.
choiceLabels: list of value(10),
choiceValues: list of value(10),
The code above works as expected, I can display the values and save them. The only problem is that since the labels have different lengths, the checkboxes look all over the place. I tried padding the labels to the right to make them all the line up, but the padding doesn't seem to do anything inside the component.
My other solution was to create multiple columns, one for each checkbox, that way they all line up. I was able to create this too, however by I cannot save the values because I don't have a static local variable to do it. I tried saving into fv!item but that throws an error. Any help or direction would be appreciated.
Here is a code snippet of what I was trying to do
items: list of 10 values at a time(array),
/*here is where I have problems saving the data*/
Discussion posts and replies are publicly visible
Saw this post today and took a crack at creating a dynamic checkbox interface. This is what I came up with
local!cols: if(isnull(ri!numOfColumns), 3, ri!numOfColumns),
local!division: length(ri!checkboxValues) / local!cols,
local!minPerCol: rounddown(local!division, 0),
local!maxPerCol: roundup(local!division, 0),
local!mod: mod(length(ri!checkboxValues), local!cols),
/* Determining the size of the row. If fv!item is <= 0 then it will be a "short" column */
fv!item - local!mod < 0,
/* Enumerate returns a value of 0 to 1-n. The array needs to be shifted by maxPerCol * fv!item */
(local!maxPerCol * fv!item) +
If the current item - mod is less than 0, or mod is 0 (meaning the number of items / number of columns is a whole number)
then 1 is added to the "shift". Otherwise, the shift will need to be SUBSTRACTED by the value of (fv!item - local!mod -1) * -1
or(fv!item - local!mod - 1 < 0, local!mod = 0),
(fv!item - local!mod - 1) * - 1
local!values: index(ri!checkboxValues, local!index),
local!labels: index(ri!checkboxLabels, local!index),
value: remove(ri!selected, rule!TCO_wherenotcontains(array: ri!selected, values: local!values)),
a!save(ri!selected, union(index(ri!selected, rule!TCO_wherenotcontains(array: ri!selected, values: local!values)), local!temp))
rule inputs are:checkboxValues: Any TypecheckboxLabels: Any Typeselcedted: Any TypenumOfColumns: Number (Integer)
© 2023 Appian. All rights reserved.