Dynamic Flex Repeater Instances

I am trying to get use to this Perspective module and some of the things are giving me some headaches. I have a view setup with three labels that is supposed to be my template. I have a Flex Repeater that is set to use said view as it’s path. I can manually set 1 or 2 or more instances of my template view, but this is not what I want. I am trying to use a tag with a script transform to tell props.instances how many template views and what values to produce. The problem is I get the error:
array found, object expected!
The proper number of template views show so I am half way there. here is what I have:

the tag is a data set with the values for the templates labels and is being transformed with this script

x = []
for row in range(value.getRowCount()):
	y = []
	cols = ["partnum", "qtyscheduled", "note"]
	for cols in range(value.getColumnCount()-1):
		y.append(value.getValueAt(row, cols))
	x.append(y)
self.props.instances = x
return self.props.instances

As the error states, the params for each instance are expected to be an object. try:

x = []
for row in range(value.getRowCount()):
	y = {}
	cols = ["partnum", "qtyscheduled", "note"]
	for i in range(value.getColumnCount()-1):
		y[cols[i]] = value.getValueAt(row, i)
	x.append(y)
self.props.instances = x
return self.props.instances

Note: I didn’t run this myself, but this will turn your inner list into a dictionary (object), which is the structure expected for each instance’s params.

That would be it. Some of my vision pieces are not translating as easy as I thought and I guess I was staring at the screen for too long. Thank you soo much. I’m glad it’s only the mobile stuff and then fresh Perspective from now on. Ha ha.

1 Like

I had to make one more change. the reason why I was iterating over the columns was because I was leaving out a column of the dataset I did not need. Doesn’t matter won’t have any effect in the negative to let it be there that I can tell it just won’t be printed.

x = []	
for row in range(value.getRowCount()):
	y = {}
	cols = ["partnum", "qtybox", "qtyscheduled", "note"]
	for i in range(value.getColumnCount()):
		y[cols[i]] = value.getValueAt(row, i)
	x.append(y)
self.props.instances = x
return self.props.instances