Flex Repeater Script Instance Additions

#1

I am trying to figure out how to dynamically add instances to a flex repeater in a Perspective View.
I’ve not seen much in the way of how to do this, but the one thread seemed to indicate there may be a bug in the functionality or not yet added functionality. Link

I did use the tolist() method to print the content of my one instance (manually entered) to the system log. This is what that looked like:
QV[{displayVal=[value, Good_Unspecified, Wed Dec 31 18:00:00 CST 1969 (941)], instancePosition=QV[{}, Good_Unspecified, Wed Dec 31 18:00:00 CST 1969], instanceStyle=QV[{classes=[, Good_Unspecified, Wed Dec 31 18:00:00 CST 1969 (941)]}, Good_Unspecified, Wed Dec 31 18:00:00 CST 1969]}, Good_Unspecified, Wed Dec 31 18:00:00 CST 1969]
I’m not sure what to make of that output!
The actual Instance of the Flex Repeater looks like the attached image.
FRInstance

So, how can a script be used to add instances to a Flex Repeater? What about SQL Queries, would they have to be wrapped in a script or is there a way to directly populate instances using queries? What other ways are there to dynamically populate these?

0 Likes

#2

Here’s what I ended up doing to programatically add instances; I run this in a message handler on my FlexRepeaters.

# Check if the instances list is empty.
# If the instances list is empty, create a new list. Otherwise, load the current list.
if (self.props.instances == None):
	currentInstances = []
else:
	currentInstances = self.props.instances.tolist()
		
newInstance = {
	# Put your instance properties here.
	}
	
currentInstances.append(newInstance)
	
self.props.instances = currentInstances
2 Likes

#3

Rather than directly manipulating the query into the right output format, you would probably be best served with a script transform that takes the query output and manipulates it into the required shape.

Also, regarding the odd script output and (imo) weird behavior of tolist, I actually just submitted changes yesterday that make the property trees much more friendly to script around; for instance, you can just directly append() a dictionary to them, and it will automatically wrap it into the required shape.

2 Likes