# Dynamically add binding to an instance of Flexrepeater

**URL:** <https://forum.inductiveautomation.com/t/dynamically-add-binding-to-an-instance-of-flexrepeater/34662>\
**Category:** General Discussion\
**Created:** [May 12, 2020, 5:24pm UTC](https://forum.inductiveautomation.com/t/dynamically-add-binding-to-an-instance-of-flexrepeater/34662 "2020-05-12T17:24:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [May 12, 2020, 5:24pm UTC](https://forum.inductiveautomation.com/t/dynamically-add-binding-to-an-instance-of-flexrepeater/34662/1 "2020-05-12T17:24:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 12, 2020, 5:31pm UTC](https://forum.inductiveautomation.com/t/dynamically-add-binding-to-an-instance-of-flexrepeater/34662/2 "2020-05-12T17:31:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [May 12, 2020, 5:33pm UTC](https://forum.inductiveautomation.com/t/dynamically-add-binding-to-an-instance-of-flexrepeater/34662/3 "2020-05-12T17:33:24Z")

</div>

Is it planned in nearest futur to add that features?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 12, 2020, 5:41pm UTC](https://forum.inductiveautomation.com/t/dynamically-add-binding-to-an-instance-of-flexrepeater/34662/4 "2020-05-12T17:41:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [May 12, 2020, 5:42pm UTC](https://forum.inductiveautomation.com/t/dynamically-add-binding-to-an-instance-of-flexrepeater/34662/5 "2020-05-12T17:42:38Z")

</div>

OK, thanks

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [May 12, 2020, 6:46pm UTC](https://forum.inductiveautomation.com/t/dynamically-add-binding-to-an-instance-of-flexrepeater/34662/6 "2020-05-12T18:46:24Z")

</div>

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?

```auto
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.

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [May 12, 2020, 7:07pm UTC](https://forum.inductiveautomation.com/t/dynamically-add-binding-to-an-instance-of-flexrepeater/34662/7 "2020-05-12T19:07:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [May 12, 2020, 7:44pm UTC](https://forum.inductiveautomation.com/t/dynamically-add-binding-to-an-instance-of-flexrepeater/34662/8 "2020-05-12T19:44:59Z")

</div>

OK, I catched what you mean…
