Nested Flex Repeater - Enable child checkboxes only within the selected row

Hi All,

I am working with a nested Flex Repeater structure in Perspective and need some guidance on the best approach.

Structure

Level 1 - Checkbox Template

  • Contains a checkbox and label.
  • Parameters:
    • type (1 = master checkbox, 2 = child checkbox)
    • value
    • enable

Level 2 - Row Template

  • Contains a Flex Repeater that uses the Checkbox Template.
  • Example row:
[Master Checkbox] [Child Checkbox] [Child Checkbox]

The logic here is working correctly:

  • When the master checkbox (type=1) is checked, the child checkboxes (type=2) in that row become enabled.
  • When the master checkbox is unchecked, the child checkboxes become disabled.

Level 3 - Main View

  • Contains another Flex Repeater that uses the Row Template.
  • Example:
Row 1 -> [Master] [Child] [Child]
Row 2 -> [Master] [Child] [Child]
Row 3 -> [Master] [Child] [Child]
...

Problem

I am currently using system.perspective.sendMessage() and a message handler to enable/disable child checkboxes.

The issue is that when I check the master checkbox in Row 1, the child checkboxes in all rows become enabled.

Example:

Row 1 Master = Checked
    -> Row 1 Childs Enabled ✅
    -> Row 2 Childs Enabled ❌
    -> Row 3 Childs Enabled ❌

Expected Behaviour

If I check the master checkbox in a specific row:

Row 1 Master = Checked
    -> Row 1 Childs Enabled ✅
    -> Row 2 No Change ✅
    -> Row 3 No Change ✅

Likewise:

Row 3 Master = Checked
    -> Row 3 Childs Enabled ✅
    -> Other Rows No Change ✅

Help me on this case

I would appreciate any examples or best practices for handling row-specific interactions within nested Flex Repeaters.

Thanks!

Any One Help me for this case !!!!

Asign an index to every master checkbox, and have that index in the child checkbox. Then, the system.perspective.sendMessage()sends the index in the payload, and you only update the rows with the correct index.
Your current code sends the message to every child.

The problem has two causes:

  1. sendMessage(scope="page") reaches every repeated row.
  2. Setting enable = True only enables children; it does not select them.

Give every row a unique rowId, include it in the message, and ignore messages belonging to other rows.

Master checkbox script:


system.perspective.sendMessage(
    "updateChildCheckboxes",
    {
        "rowId": self.view.params.rowId,
        "checked": bool(currentValue.value)
    },
    scope="page"
)

Message handler inside the Row Template:


# Ignore messages for other rows
if payload.get("rowId") != self.view.params.rowId:
    return

checked = bool(payload.get("checked", False))
repeater = self.getChild("CheckboxRepeater")

new_instances = []

for instance in repeater.props.instances:
    item = dict(instance)

    if int(item.get("type", 0)) == 2:
        item["enable"] = checked
        item["value"] = checked   # Select/unselect the child

    new_instances.append(item)

# Assign a new list so Perspective detects the change
repeater.props.instances = new_instances

Each Level 3 instance must contain a different ID:


[
    {"rowId": 1},
    {"rowId": 2},
    {"rowId": 3}
]

This makes the master checkbox affect and select only the children in its own row.