# Perspective Table Edit certain cells and write into DB

**URL:** <https://forum.inductiveautomation.com/t/perspective-table-edit-certain-cells-and-write-into-db/40917>\
**Category:** Ignition\
**Tags:** perspective, ignition80\
**Created:** [November 24, 2020, 10:39am UTC](https://forum.inductiveautomation.com/t/perspective-table-edit-certain-cells-and-write-into-db/40917 "2020-11-24T10:39:06Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [November 24, 2020, 4:05pm UTC](https://forum.inductiveautomation.com/t/perspective-table-edit-certain-cells-and-write-into-db/40917/2 "2020-11-24T16:05:40Z")

</div>

> [@Gaurav.Shitole](#):
>
> How do I make certain cell ‘editable’ automatically when the table.props.data changes

I would recommend against trying to do this with a 'value change' script - instead, just add a transform to your data fetch.

If you're pulling the data out of a database already, then it should be fairly easy to write a transform - something like the process defined here (although that post assumes your data is coming in as a dataset, not a json array):

> [@Perspective Table - Invididual Cell Conditional Formatting](http://forum.inductiveautomation.com/t/perspective-table-invididual-cell-conditional-formatting/39371/4):
>
> A maybe more maintainable variation, if you ever intend on adding other columns you need to style: def cc\_msval(v, r, c): style\_orange = {"backgroundColor": "#F7901D"} style\_green = {"backgroundColor": "#00AA00"} return { "value": v.getValueAt(r, c), "style": style\_orange if v.getValueAt(r, c) \< 95 else style\_green } transforms = { "CC\_msval": cc\_msval } return [ { value.getColumnName(col): transforms.get(value.getColumnName(col), lambda v, r, c: v.getValueAt(r, c))(v…

* * *

> [@Gaurav.Shitole](#):
>
> I have created a script to write updated values into DB, but not sure if its a safe and standard way.

I don't see any big problems with your script. Coping the values into the `updatedData` list and then looping over that list is unnecessary - you could just loop through the table's data array directly:

```python
	table = self.getSibling("Table")	
	recipeID = self.getSibling("Dropdown").props.value

	#pulling updated values from table and putting into a list
	for row in table.props.data:
		newValue = row['CONTROL SP']
		ID = row['ID']
			
		params = {
			"id": ID,
			"recipeId": recipeId,
			"newValue": newValue
		}
		
		system.db.runNamedQuery('ProjName', 'UpdateQueries/ControlSetpoints', params)
	
	table.refreshBinding("props.data")

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/perspective-table-edit-certain-cells-and-write-into-db/40917)._
