How to access selection of a row of a table in a icon script

def runAction(self, event):
	if (self.parent.parent.parent.parent.parent.getChild("Table").onSelectionchange(event.selectedRow)==1):
		params = {'id':self.parent.parent.parent.parent.parent.getChild("Table")[0].ID}
		system.db.runNamedQuery("Delete_Rows", params)
		system.perspective.openPopup("AlertId",view,params={'display':"Select the row to be Deleted"} )

i want to know whether the row has been selected or not
additionally is the popup id correct if not how to get it

Relative paths vs custom properties
As I'm sure you have found, self.parent.parent.parent.parent.parent.getChild syntax is awkward to set up, difficult to read and very hard to maintain when components are moved in a view. Try this:

  • On the view, create a custom property to hold a copy of the table data you are examining.
  • Create a Property Binding on that table property, point it at the custom property and set the binding to bidirectional.
  • Now you can replace the awkward syntax with self.view.custom.myCustomProp or whatever you called it.

Row selected or not

i want to know whether the row has been selected or not.

Create a view.custom.selectedRow property. Bind table props.selection.selectedRow to the custom property with a bidirectional property binding.
Now you can use
if self.view.custom.selectedRow:
A non-null value indicates that a row is selected.


additionally is the popup id correct if not how to get it

You don't need the popup. Disable or hide the delete button if no row has been selected. Don't waste the user's time by presenting options that won't work.

Thanks a lot i will try it

I send you an onActionPerformed Script I did with the help of Transistor in case it helps:

def runAction(self, event):
	# Reference the table component directly
	table = self.getSibling("tblWorkRequest")
	# Retrieve the selected rows
	selected_rows =
	# Check if any row is selected
	if not selected_rows:
	    system.perspective.messageBox("Please select a row to process", title="Notice")
	    # Process the first selected row (if only one row is expected)
	    selected_row = selected_rows[0]
	    # Extract specific columns' data using the column names
	    sede = selected_row.get("SEDE")  # Replace with the actual column name
	    solicitud = selected_row.get("SOLICITUD")  # Replace with the actual 
              column name
	    popup_params = {
	        "sede": sede,
	        "solicitud": solicitud
	    # Open the popup view, passing the parameters
	        id="aprobar-popup",  # A unique identifier for this popup instance
	        title="Aprobar Solicitud",


i can't comprehend it correctly
let me explain it if i am wrong correct me , i want to create a custom property in view or page and write the view.custom.selectedRow in it and bind it to table proprety data or something like that please explain with a example

I think I would have told you the same thing. Disable the button if no row is selected. Don't have unnecessary popups to annoy the user.

1 Like

but the highers want that function so i have to do it

Sorry, it is just wrong and bad GUI design.

What is their specification?

Yes, you right, I just fixed it up, so the user get a message in case they didn´t select any row to remind them to do so.

	selected_rows =

	if not selected_rows:
            id="noneSelected-popup",  # A unique identifier for this popup instance
            title="No hay fila seleccionada",


But there is no need!
Disable the button until the user selects a row!

Is row selected

Expression binding on button's enabled property.

No script code.
No popup.
No time wasted by the designer (once) or the user (every day).

1 Like

but if i bind table to that property what about query update

1 Like

if i change it to a relative path i can't access the selection function

Caused by: org.python.core.PyException: AttributeError: 'com.inductiveautomation.ignition.gateway.datasourc' object has no attribute 'selection'

it shows error like this help me transistor

Your script becomes something like this:

def runAction(self, event):
	# If button was enabled then a row has been selected.
	params = {'id': self.view.custom.selectedRow[0].ID}
	system.db.runNamedQuery("Delete_Rows", params)


	# Refresh the table binding to show the updated records.
	system.perspective.sendMessage("tableRefresh", payload = {}, scope = "view")

Then on the table you right-click, Configure Scripts, ...

1 Like