# Perspective table disable editing on certain rows

**URL:** <https://forum.inductiveautomation.com/t/perspective-table-disable-editing-on-certain-rows/52016>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 15, 2021, 10:08pm UTC](https://forum.inductiveautomation.com/t/perspective-table-disable-editing-on-certain-rows/52016 "2021-10-15T22:08:15Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [October 15, 2021, 10:08pm UTC](https://forum.inductiveautomation.com/t/perspective-table-disable-editing-on-certain-rows/52016/1 "2021-10-15T22:08:15Z")

</div>

I am using a Perspective application to manage passwords for our various control systems. Based on the user’s rights they will be able to see the password or ‘\*\*\*\*\*\*\*\*’. If they have rights to the password they can edit that row.

In the `onCellCommit` event I have added the lines below to prevent them updating rows for which they do not have sufficient rights.

```auto
	r = event['row'] # The Perspective table row number.
	if not self.props.data[r].canEdit: # This user is not allowed edit this db table row.
		return # Do nothing.

```

This works but it rejects the edit _after_ the event.

How can I deselect the cell by code if the operator selects the cell but doesn’t have authorisation? It would be a line or two to be added to the `onSelectionChanged` event. Any better ideas?  
Many thanks.

---

<div class="post-metadata">

**Author:** ![jhansen](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@jhansen](https://forum.inductiveautomation.com/u/jhansen)\
**Post date:** [October 16, 2021, 5:42am UTC](https://forum.inductiveautomation.com/t/perspective-table-disable-editing-on-certain-rows/52016/2 "2021-10-16T05:42:23Z")

</div>

You can use the onCellEditStart function to preserve the value pre-edit. In this function, you can simply set props.selection.selectedRow and props.selection.selectedColumn to null to remove the selection as soon as an operator attempts to edit a cell.

---

<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:** [October 16, 2021, 12:20pm UTC](https://forum.inductiveautomation.com/t/perspective-table-disable-editing-on-certain-rows/52016/3 "2021-10-16T12:20:37Z")

</div>

Thank you for your reply.

If I use the default table and add this code to the `onEditCellStart`

```auto
	r = event['row'] # The Perspective table row number.
	if self.props.data[r].city == 'Helsinki': # This user is not allowed edit this db table row.
		system.perspective.print("Exiting edit.")
		self.props.selection.selectedRow = None
		self.props.selection.selectedColumn = None

```

… the cell remains in edit mode.  
Why?

Interestingly, I have _cells, allowEditOn : single-click_ and the _onEditCellStart_ event is fired when a cell is selected (which doesn’t turn on editing) and again when the cell is clicked a second time (which does turn on cell editing). Why is the event fired the first time?
