# Dynamic Column Editable

**URL:** <https://forum.inductiveautomation.com/t/dynamic-column-editable/26363>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [July 8, 2019, 7:12pm UTC](https://forum.inductiveautomation.com/t/dynamic-column-editable/26363 "2019-07-08T19:12:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![MSmoger](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@MSmoger](https://forum.inductiveautomation.com/u/MSmoger)\
**Post date:** [July 8, 2019, 7:12pm UTC](https://forum.inductiveautomation.com/t/dynamic-column-editable/26363/1 "2019-07-08T19:12:30Z")

</div>

Is there a way to do the following in a power table:  
if Column A (Boolean) is checked turn off editable in Column B.

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [July 8, 2019, 7:24pm UTC](https://forum.inductiveautomation.com/t/dynamic-column-editable/26363/2 "2019-07-08T19:24:55Z")

</div>

If you go into the scripting for the power table you should be able to use the isCellEditable function to determine if an individual cell can be edited. You would just have to do a check on your dataset for the boolean in the same row.

---

<div class="post-metadata">

**Author:** ![MSmoger](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@MSmoger](https://forum.inductiveautomation.com/u/MSmoger)\
**Post date:** [July 8, 2019, 7:28pm UTC](https://forum.inductiveautomation.com/t/dynamic-column-editable/26363/3 "2019-07-08T19:28:33Z")

</div>

I am very new to Ignition. Can you provide me with an example?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 8, 2019, 7:52pm UTC](https://forum.inductiveautomation.com/t/dynamic-column-editable/26363/4 "2019-07-08T19:52:53Z")

</div>

Take a look at this thread, and post back here if you have any questions.

Oh, and welcome to the forums! 🙂

> [@Power table block entry to a cell](http://forum.inductiveautomation.com/t/power-table-block-entry-to-a-cell/22446):
>
> How do you block entry to a certain cell on the onCellEditable function

---

<div class="post-metadata">

**Author:** ![MSmoger](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@MSmoger](https://forum.inductiveautomation.com/u/MSmoger)\
**Post date:** [July 9, 2019, 6:13pm UTC](https://forum.inductiveautomation.com/t/dynamic-column-editable/26363/5 "2019-07-09T18:13:52Z")

</div>

I think I am close but I still can’t get this to work. Here is what I have in the onCellEdited on my power table:

`
	data = self.data
	if colName == "LeakFound":
```
	if data.getValueAt(rowIndex,"NoLeakFound")==1:
		return False
	else:
		return True
elif colName == "NoLeakFound":
	return False
else:
	return True

value = newValue
value = str(value)
	
table = self.data
dataset = self.name
pythonDataset = system.dataset.toPyDataSet(table)
	
id = pythonDataset[rowIndex][0]
	
query = "UPDATE AirLeak SET " + str(colName) + " = ?"
query = query + " WHERE id = ? "
	
values = [value, id]
	
system.db.runPrepUpdate(query, values)
system.db.refresh(self, 'data')

```
`

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [July 9, 2019, 6:26pm UTC](https://forum.inductiveautomation.com/t/dynamic-column-editable/26363/6 "2019-07-09T18:26:10Z")

</div>

What are you trying to do with the return False and return True in the onCellEdited? I’m assuming that part of it should be in the isCellEditable. Also what your doing with value can be done in one line. Same with query

```auto
value = str(newValue)

query = "UPDATE AirLeak SET " + str(colName) + " = ? WHERE id = ? "

```

Also what errors are you getting? The error messages in your log will give you a good idea where to look in your script.

---

<div class="post-metadata">

**Author:** ![MSmoger](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@MSmoger](https://forum.inductiveautomation.com/u/MSmoger)\
**Post date:** [July 9, 2019, 6:57pm UTC](https://forum.inductiveautomation.com/t/dynamic-column-editable/26363/7 "2019-07-09T18:57:35Z")

</div>

I am not getting an error in the console. When I click on a cell nothing happens. The cell should go from uncheck to checked and it is not. And with no changes being made it does not update my SQL table. I am trying to make it so when the column NoLeakFound is check I can not edit the LeakFound column.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [July 9, 2019, 7:02pm UTC](https://forum.inductiveautomation.com/t/dynamic-column-editable/26363/8 "2019-07-09T19:02:12Z")

</div>

Put the first part of code in the _isCellEditable_ extension function.

```auto
data = self.data 
if data.getValueAt(rowIndex,"NoLeakFound") == 0: 
	if colName == "LeakFound"
                 return True
else:
	return False

```

Then put the query part in the _onCellEdited_ extension function

```auto
ndx = self.data.getValueAt(rowIndex,0)
system.db.runPrepUpdate("UPDATE AirLeak SET %s=? WHERE AirLeak_ndx=?"%colName, [newValue,ndx])
system.db.refresh(self,"data")

```

---

<div class="post-metadata">

**Author:** ![MSmoger](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@MSmoger](https://forum.inductiveautomation.com/u/MSmoger)\
**Post date:** [July 9, 2019, 8:44pm UTC](https://forum.inductiveautomation.com/t/dynamic-column-editable/26363/9 "2019-07-09T20:44:01Z")

</div>

I made the changes you recommended. I get the process to work. Thank you ALL for your knowledge and willingness to help. 🙂
