# Dynamic property path in table

**URL:** <https://forum.inductiveautomation.com/t/dynamic-property-path-in-table/46770>\
**Category:** Ignition\
**Created:** [May 17, 2021, 12:56pm UTC](https://forum.inductiveautomation.com/t/dynamic-property-path-in-table/46770 "2021-05-17T12:56:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adriaan.leRoux](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@Adriaan.leRoux](https://forum.inductiveautomation.com/u/Adriaan.leRoux)\
**Post date:** [May 17, 2021, 12:56pm UTC](https://forum.inductiveautomation.com/t/dynamic-property-path-in-table/46770/1 "2021-05-17T12:56:59Z")

</div>

Hi there

I am trying to change the style property of a table dynamically, it is a table with times as rows and days as columns

the columns are d1,d2,d3 up to d31

I want to change the tables style depending on the time, so I have two nested loops

```auto
for i in range(0,12,1):
			
		for j in range(1,32,1)
		
			self.props.data[i].d1.style.classes = "LoadShedding/Cell_Normal"

```

I want to iterate through this from d1 to d31 using the ‘j’ variable. How do I accomplish this?

I need to select more than one cell at a time, so I can’t just modify the selected values in the table’s properties

I am using perspective 8.1

---

<div class="post-metadata">

**Author:** ![matthew.ayre](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matthew.ayre/32/19499_2.png) [@matthew.ayre](https://forum.inductiveautomation.com/u/matthew.ayre)\
**Post date:** [May 17, 2021, 1:05pm UTC](https://forum.inductiveautomation.com/t/dynamic-property-path-in-table/46770/2 "2021-05-17T13:05:58Z")

</div>

Hi @Adriaan.leRoux, you can do this via creating the data structure on the binding.

[This](http://forum.inductiveautomation.com/t/change-style-of-cell-component-table-via-script-perspective/44573/2) may help, but I can explain further if you need it.

Edit: updated the link, I posted the wrong one 😅

---

<div class="post-metadata">

**Author:** ![Adriaan.leRoux](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@Adriaan.leRoux](https://forum.inductiveautomation.com/u/Adriaan.leRoux)\
**Post date:** [May 17, 2021, 1:38pm UTC](https://forum.inductiveautomation.com/t/dynamic-property-path-in-table/46770/3 "2021-05-17T13:38:18Z")

</div>

Thanks for the reply.

Excuse the ‘C++’ speak, but are you essentially saying that I should not think about this data[] array as an array of classes but instead see it as an array of strings? These strings being formatted like a you would see if you copied and pasted that index into notepad? JSON right?

---

<div class="post-metadata">

**Author:** ![matthew.ayre](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matthew.ayre/32/19499_2.png) [@matthew.ayre](https://forum.inductiveautomation.com/u/matthew.ayre)\
**Post date:** [May 17, 2021, 1:49pm UTC](https://forum.inductiveautomation.com/t/dynamic-property-path-in-table/46770/4 "2021-05-17T13:49:15Z")

</div>

No worries. Right, this is how I interpret it (which may not be correct, but it’s how it works in my head). The data array is an Ignition array of Ignition objects. However, when you create the data array via a script binding, Ignition will implicitly convert python lists to Ignition arrays and python dictionaries to Ignition objects.

Note: be careful as I believe Ignition types do not implicitly convert back (e.g. an Ignition object will not convert back to a python dictionary implicitly).

The link is an example of creating the data array of objects in a way that allows you to style each individual cell. For the column dictionary key you should be able to use string concatenation to give you the appropriate key for your column.

---

<div class="post-metadata">

**Author:** ![Adriaan.leRoux](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@Adriaan.leRoux](https://forum.inductiveautomation.com/u/Adriaan.leRoux)\
**Post date:** [May 17, 2021, 1:50pm UTC](https://forum.inductiveautomation.com/t/dynamic-property-path-in-table/46770/5 "2021-05-17T13:50:42Z")

</div>

Thanks a bunch, I will let you know how it goes

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 17, 2021, 1:57pm UTC](https://forum.inductiveautomation.com/t/dynamic-property-path-in-table/46770/6 "2021-05-17T13:57:24Z")

</div>

Try this:

```auto
for i in range(0,12,1):
	for j in range(1,32,1)
		dj = getattr(self.props.data[i], 'd'+str(j))
		dj.style.classes = "LoadShedding/Cell_Normal"

```

`getattr` is a python/jython builtin function for property (attribute) access. See also `setattr` for leaf attributes.

---

<div class="post-metadata">

**Author:** ![Adriaan.leRoux](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@Adriaan.leRoux](https://forum.inductiveautomation.com/u/Adriaan.leRoux)\
**Post date:** [May 17, 2021, 2:24pm UTC](https://forum.inductiveautomation.com/t/dynamic-property-path-in-table/46770/7 "2021-05-17T14:24:40Z")

</div>

@pturmel I looked at that function, but it seemed to return actual values, not a reference. Is that returning a pointer?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 17, 2021, 4:01pm UTC](https://forum.inductiveautomation.com/t/dynamic-property-path-in-table/46770/8 "2021-05-17T16:01:47Z")

</div>

It should return the object. Stringification would happen if you used it in any non-object way.

---

<div class="post-metadata">

**Author:** ![Adriaan.leRoux](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@Adriaan.leRoux](https://forum.inductiveautomation.com/u/Adriaan.leRoux)\
**Post date:** [May 18, 2021, 6:42am UTC](https://forum.inductiveautomation.com/t/dynamic-property-path-in-table/46770/9 "2021-05-18T06:42:57Z")

</div>

@pturmel Works like a charm! Thanks!
