Manually adding items to on Table is being overwritten on first write

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 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 array.


Here is the onRowClick event script I am using:

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

Is there a fix for this?

Should I add a onChange check to the to resync the table ui?

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

1 Like

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