# Manually adding items to props.selection.data on Table is being overwritten on first write

**URL:** <https://forum.inductiveautomation.com/t/manually-adding-items-to-props-selection-data-on-table-is-being-overwritten-on-first-write/78147>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 21, 2023, 11:11am UTC](https://forum.inductiveautomation.com/t/manually-adding-items-to-props-selection-data-on-table-is-being-overwritten-on-first-write/78147 "2023-08-21T11:11:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [August 21, 2023, 11:11am UTC](https://forum.inductiveautomation.com/t/manually-adding-items-to-props-selection-data-on-table-is-being-overwritten-on-first-write/78147/1 "2023-08-21T11:11:42Z")

</div>

I am trying in implement a multi-data point selection with a onClick Add and Remove for my table

I have noticed , that when trying to add a item to the `props.selection.data` for the first cycle , the array gets reset but any attempt afterwards, works perfectly fine.

This is issue causes ui to fall out of sync with what is actually inside the `props.selection.data` array.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/b/5bdede7bc2f8c94a7711249df8a4e48ce697c7c9.png)

Here is the onRowClick event script I am using:

```auto
	rowIndex=event.row
	self.props.data[rowIndex].selected=not self.props.data[rowIndex].selected
	
	# check if row is selected
	if self.props.data[rowIndex].selected:
		# if row is not inside selection data , add it
		if self.props.data[rowIndex].BatchID not in [x['BatchID'] for x in self.props.selection.data]:
			self.props.selection.data.append(self.props.data[rowIndex])
		
	else:
		# if row is not selected
		
		data={x['BatchID']:i for i,x in enumerate(self.props.selection.data)}
		# if row is in selection data , remove it.
		if self.props.data[rowIndex].BatchID in data.keys():
			self.props.selection.data.pop(data[self.props.data[rowIndex].BatchID])

```

Is there a fix for this?

Should I add a onChange check to the `props.selection.data` to resync the table ui?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 21, 2023, 12:19pm UTC](https://forum.inductiveautomation.com/t/manually-adding-items-to-props-selection-data-on-table-is-being-overwritten-on-first-write/78147/2 "2023-08-21T12:19:29Z")

</div>

It's probably not going to work for you. There is some good explanation here:

> [@Select all rows in a perspectives table](https://forum.inductiveautomation.com/t/select-all-rows-in-a-perspectives-table/77475/6):
>
> Unfortunately, Table.props.selection.data is read-only, and writing data to that property will not modify the state or appearance of the Table. The primary reason for this is that there is no guarantee of uniqueness in Table data. Imagine you had a Table with a single column "x" (just to keep the example simple), and it only had three rows: x ----- 1 2 1 Suppose now that you wrote the row data for the 2th (3rd) row with the expectation that the 2th row would display as selected. Well.…

---

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [August 21, 2023, 12:34pm UTC](https://forum.inductiveautomation.com/t/manually-adding-items-to-props-selection-data-on-table-is-being-overwritten-on-first-write/78147/3 "2023-08-21T12:34:33Z")

</div>

I ended up using a custom property to stored selected data which resolved this issue.
