Dynamically add binding to an instance of Flexrepeater

I want to generate dynamically instances of a flexrepeater and i also want to add binding to some values.

My code is:
tags = system.tag.browseTags(parentPath=value)

instances = []
for tag in tags:
	dict={}
	dict["instanceStyle"]={}
	dict["instanceStyle"]["classes"]=""
	dict["instancePosition"]={}
	dict["title"] = "tp_item_" + tag.fullPath.rsplit("/",1)[1] + "_title"
	dict["description"] = "tp_item_" + tag.fullPath.rsplit("/",1)[1] + "_desc"
	dict["value"]={"binding": {"config": {"bidirectional": True,"fallbackDelay": 2.5,"mode": "indirect","references": {"path": "{view.params.path}"},"tagPath": "{path}/setup/items/" + tag.fullPath.rsplit("/",1)[1] + "/state/installed"},"type": "tag"}}
		
	instances.append(dict)
return instances

My problem is on binding, I got all objects in the value and not as binding…

How can I fix it?

You can’t create bindings dynamically. The closest you can get, at the moment, would be manually creating/modifying the view.json file on disk for a particular view, but it would be pretty hard to do that in a dynamic way based on other changes happening in your project.

Is it planned in nearest futur to add that features?

In the near future, nothing that I’ve heard about. The only related idea (not an actual specific feature that’s definitely going to be implemented) I’ve heard of is a kind of ‘dynamic view’, where the view config is fetched on-demand by running a Python script or something similar on the backend.

OK, thanks

Why don’t use use what would have been the bound value as a param to the view and let the view manage the binding?

In your case, build something like tagPath as a param for the instance, and let the View bind some value against the supplied tagPath?

tags = system.tag.browseTags(parentPath=value)
instances = []
for tag in tags:
    # also, "dict" actually means something in Python, so you shouldn't use it as a variable name.
	my_dict={}
	my_dict["instanceStyle"]={}
	my_dict["instanceStyle"]["classes"]=""
	my_dict["instancePosition"]={}
	my_dict["title"] = "tp_item_" + tag.fullPath.rsplit("/",1)[1] + "_title"
	my_dict["description"] = "tp_item_" + tag.fullPath.rsplit("/",1)[1] + "_desc"
	my_dict['tagPath'] = self.view.params + "/setup/items/" + tag.fullPath.rsplit("/",1)[1] + "/state/installed"
		
	instances.append(dict)
return instances

Then just set up the View you are instancing to use the tagPath param in a binding.

1 Like

I want to have all my instances dynamic. I want to add instance according to the UDT linked. I never have the same number of instance and when I add the array builded to the instances I don’t found the to bind the values requested.

I’m not sure to undertand what you explain. Can you be more explicit or send screen shot.

OK, I catched what you mean…