# To Delete a selected row in Perspective using a icon

**URL:** <https://forum.inductiveautomation.com/t/to-delete-a-selected-row-in-perspective-using-a-icon/90340>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 14, 2024, 4:21am UTC](https://forum.inductiveautomation.com/t/to-delete-a-selected-row-in-perspective-using-a-icon/90340 "2024-05-14T04:21:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Selvapandiaraj\_A](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@Selvapandiaraj\_A](https://forum.inductiveautomation.com/u/Selvapandiaraj_A)\
**Post date:** [May 14, 2024, 4:21am UTC](https://forum.inductiveautomation.com/t/to-delete-a-selected-row-in-perspective-using-a-icon/90340/1 "2024-05-14T04:21:28Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/7/37a40912b48ef08d76af79d1b6c97c9f8ed9a6c8.png)  
In this picture i want to add click on script in icon

```python
def runAction(self, event):
	row_id = self.parent.parent.parent.parent.parent.getChild("Table").selection.selectedRow
	row = self.getSibling("Table").props.data.pop(row_id)
	system.db.runNamedQuery("Delete_Rows", parameters=row)
	
	self.parent.parent.parent.parent.parent.getChild("Table").refreshBinding("props.data")

```

```
this the script 

```

i have a named query Delete\_Rows

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/9/39186ede9434a616c945a36b4459efb23aa7c5e3.png)  
this the named query details so tell me what to do  
Any help is welcomed

---

<div class="post-metadata">

**Author:** ![hunterdg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hunterdg/32/67774_2.png) [@hunterdg](https://forum.inductiveautomation.com/u/hunterdg)\
**Post date:** [May 14, 2024, 4:51am UTC](https://forum.inductiveautomation.com/t/to-delete-a-selected-row-in-perspective-using-a-icon/90340/2 "2024-05-14T04:51:23Z")

</div>

> [@Selvapandiaraj\_A](#):
>
> `self.parent.parent.parent.parent.parent.getChild("Table")`

alternatives:

```python
self.view.getChild("root").getChild("Table")...
self.view.getRootContainer().getChild("Table")...
self.view.rootContainer.getChild("Table")...

```

Expression equivalent:  
~~`view.root...`~~  
`{/root/Table...}`

---

<div class="post-metadata">

**Author:** ![Selvapandiaraj\_A](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@Selvapandiaraj\_A](https://forum.inductiveautomation.com/u/Selvapandiaraj_A)\
**Post date:** [May 14, 2024, 4:54am UTC](https://forum.inductiveautomation.com/t/to-delete-a-selected-row-in-perspective-using-a-icon/90340/3 "2024-05-14T04:54:56Z")

</div>

i want to know the syntax for using selected row or how to use them

---

<div class="post-metadata">

**Author:** ![hunterdg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hunterdg/32/67774_2.png) [@hunterdg](https://forum.inductiveautomation.com/u/hunterdg)\
**Post date:** [May 14, 2024, 4:57am UTC](https://forum.inductiveautomation.com/t/to-delete-a-selected-row-in-perspective-using-a-icon/90340/4 "2024-05-14T04:57:20Z")

</div>

this may work:

```python
	row = self.getSibling("Table").props.data.get(row_id)
	system.db.runNamedQuery("Delete_Rows", parameters={"id"=row})

```

---

<div class="post-metadata">

**Author:** ![hunterdg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hunterdg/32/67774_2.png) [@hunterdg](https://forum.inductiveautomation.com/u/hunterdg)\
**Post date:** [May 14, 2024, 4:59am UTC](https://forum.inductiveautomation.com/t/to-delete-a-selected-row-in-perspective-using-a-icon/90340/5 "2024-05-14T04:59:33Z")

</div>

> **[system.db.runNamedQuery | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-db/system-db-runNamedQuery#code-examples:~:text=Simple%20Example%20%2D%20With%20Parameters)**
>
> Runs a named query and returns the results.

---

<div class="post-metadata">

**Author:** ![Selvapandiaraj\_A](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@Selvapandiaraj\_A](https://forum.inductiveautomation.com/u/Selvapandiaraj_A)\
**Post date:** [May 14, 2024, 5:02am UTC](https://forum.inductiveautomation.com/t/to-delete-a-selected-row-in-perspective-using-a-icon/90340/6 "2024-05-14T05:02:04Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/6/36a25b1bb77da4f9355a688b0e128cc8d5ca7852.png)  
it shows a error like this AttributeError

---

<div class="post-metadata">

**Author:** ![hunterdg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hunterdg/32/67774_2.png) [@hunterdg](https://forum.inductiveautomation.com/u/hunterdg)\
**Post date:** [May 14, 2024, 5:04am UTC](https://forum.inductiveautomation.com/t/to-delete-a-selected-row-in-perspective-using-a-icon/90340/7 "2024-05-14T05:04:12Z")

</div>

> [@hunterdg](#):
>
> ```python
> self.view.getChild("root").getChild("Table")...
> self.view.getRootContainer().getChild("Table")...
> 
> ```

you need to sort this out. your code has both `self.getSibling("Table")` and `self.parent.parent.parent.parent.parent.getChild("Table")`

---

<div class="post-metadata">

**Author:** ![Selvapandiaraj\_A](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@Selvapandiaraj\_A](https://forum.inductiveautomation.com/u/Selvapandiaraj_A)\
**Post date:** [May 14, 2024, 5:07am UTC](https://forum.inductiveautomation.com/t/to-delete-a-selected-row-in-perspective-using-a-icon/90340/8 "2024-05-14T05:07:37Z")

</div>

i tried your code same result

---

<div class="post-metadata">

**Author:** ![hunterdg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hunterdg/32/67774_2.png) [@hunterdg](https://forum.inductiveautomation.com/u/hunterdg)\
**Post date:** [May 14, 2024, 5:12am UTC](https://forum.inductiveautomation.com/t/to-delete-a-selected-row-in-perspective-using-a-icon/90340/9 "2024-05-14T05:12:34Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/6/36a25b1bb77da4f9355a688b0e128cc8d5ca7852.png)  
this literally means `self.getSibling("Table")` is wrong ('NoneType object has no attribute 'props')

try browsing to the 'data' property with the GUI:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/1/a1ff330772589a5823cc33fc35636e9745edbd5d.png)

---

<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:** [May 14, 2024, 7:23am UTC](https://forum.inductiveautomation.com/t/to-delete-a-selected-row-in-perspective-using-a-icon/90340/10 "2024-05-14T07:23:45Z")

</div>

First understand the parent and child relationships. In your other quesiont, [refreshBinding not working probably because not called on the right object - #10 by Transistor](https://forum.inductiveautomation.com/t/refreshbinding-not-working-probably-because-not-called-on-the-right-object/60172/10), you have the structure,

```python
root
  + Flexcontainer
    + Button
  + Table

```

So, to get from Button to Table you have to go `parent` (which takes you to Flexcontainer) then you use `getSibling` to get to Table.

Alternately, you could go `parent.parent` which takes you to `root` and then use `getChild` to get to Table.

If we examine your code below we can see that you have been inconsistent with the relative paths and they are very deep. You can avoid errors if you use the Property Inspector to create the paths for you as shown by Ujwal in the previous question.

```python
def runAction(self, event):
	row_id = self.parent.parent.parent.parent.parent.getChild("Table").selection.selectedRow
	row = self.getSibling("Table").props.data.pop(row_id)
	system.db.runNamedQuery("Delete_Rows", parameters=row)
	
	self.parent.parent.parent.parent.parent.getChild("Table").refreshBinding("props.data")

```

* * *

**Other problems**

1. Where did you find documentation on using `pop` on a table properties? I can't find it anywhere.

2. To delete a row `WHERE id = :id` you need to retrieve the `id` value from the selected row. Your screengrab doesn't show that column. Maybe you have called it `row_id` but haven't shown it.

3. `runNamedQuery` expects a dictionary of parameters. You haven't supplied one.

4. We don't know the relative paths between your components. Please add a screengrab from Project Browser showing the relative positions of the delete button and the table.

5. Add the `id` column to your table if it is not there already. Show that in a screengrab.
