I have created Flex repeater with checkbox template. On change of checkbox, message handler is called. In the message handler received I am fetching the flex repeater instances. But Flex repeater instance updating after 0.5 sec of check box change. Please help me to solve the issue.
Thanks
In the message handler I am fetching the flex repeater instances.
Usually, this is what I would do to get instant Flex Repeaters instances
modification:
- Create view to be repeated (your checkbox template). Add a view param called
index
on your checkbox view. Add another view param called value
. Bind the Checkbox's selected
property to self.view.params.value
.
- Create a different view with Flex Repeater in it. Set the path to the first view from step 1. Add some test instances. DON'T pass in the
index
parameter from the Flex Repeater, it'll get passed in automatically!!! (read docs for Flex Repeater).
- Create a Message Handler on the Flex Repeater, call it something like
update_instance
and keep the scope at page
. In this message handler, you'll be listening for checkbox changes and update the correct one with a script like this:
index = payload["index"] # index of instance to modify
value = payload["value"] # new value (either True/False, 0/1, etc)
# update the instance with new state of checkbox
self.props.instances[index].value = value
- Go back to the view with the Checkbox. On the Checkbox component, add a script on the
onActionPerformed
event and place this there:
payload = {
"index": self.view.params.index,
"value": self.props.selected
}
system.perspective.sendMessage("update_instance", payload)
Now if you go back to your view with the Flex Repeater, focus on the Flex Repeater in the Project Browser and hit the Preview mode, you'll be able to change the checkboxes in the Flex Repeater and they'll change instantly in the instances
list.
[Doing this all from memory so if something doesn't work, let me know and I'll correct it!]
2 Likes
It's working... Thank you so much