# Customizing Alarm status table

**URL:** <https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [June 23, 2022, 9:22am UTC](https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102 "2022-06-23T09:22:53Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Halvor\_Johnsen](https://avatars.discourse-cdn.com/v4/letter/h/ee7513/32.png) [@Halvor\_Johnsen](https://forum.inductiveautomation.com/u/Halvor_Johnsen)\
**Post date:** [June 23, 2022, 9:22am UTC](https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102/1 "2022-06-23T09:22:53Z")

</div>

Hi,

Is it possible to customize the Alarm Status Table, f.eks. changig name of colums etc.?

---

<div class="post-metadata">

**Author:** ![Mikhail\_Simin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mikhail_simin/32/35931_2.png) [@Mikhail\_Simin](https://forum.inductiveautomation.com/u/Mikhail_Simin)\
**Post date:** [June 23, 2022, 5:25pm UTC](https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102/2 "2022-06-23T17:25:13Z")

</div>

Are you using the Alarm Status Table in Vision or Perspective?

---

<div class="post-metadata">

**Author:** ![Halvor\_Johnsen](https://avatars.discourse-cdn.com/v4/letter/h/ee7513/32.png) [@Halvor\_Johnsen](https://forum.inductiveautomation.com/u/Halvor_Johnsen)\
**Post date:** [June 27, 2022, 6:08am UTC](https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102/3 "2022-06-27T06:08:13Z")

</div>

Hi,

I am using the Alarm Status Table in Vision.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [December 15, 2022, 7:26am UTC](https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102/4 "2022-12-15T07:26:11Z")

</div>

> [@Halvor\_Johnsen](#):
>
> Alarm Status Table, f.eks. changig name of colums

I recently developed a way to accomplish this. Here is the code:

```auto
def columnLabeler(alarmStatusTable):
	if alarmStatusTable.componentCount > 0:
		for table in alarmStatusTable.getComponents():
			if 'AlarmStatusTable$1' in str(table. __class__ ):
				tableHeaders= table.getTableHeader()
				columnModel = table.getColumnModel()
				for column in range(table.columnCount):
					tableColumn = columnModel.getColumn(column)
					tableColumn.setHeaderValue("Custom Column Name " + str(column + 1))
				tableHeaders.repaint()
			columnLabeler(table)
alarmStatusTable = event.source.parent.getComponent('Alarm Status Table')
columnLabeler(alarmStatusTable)

```

The code finds the table within the component, and then loops through the columns using normal jtable methods to apply custom headers. This version is written for the actionPerformed event handler of a button in the same container as the Alarm Status Table.

The preceding code produces the following result:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/2/3251e37680150fc6b1351c301efc7cde605eb1f6.png)

One thing that is interesting about the code is that even if the client hides and reshows the column, the table remembers the replacement name. That said, the code will have to be ran from either an onInternalFrameOpened event script or something that works in this way, because if the window is _closed_, the table will not remember the next time the window is _opened_.

---

<div class="post-metadata">

**Author:** ![Priyanka.Khandge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/priyanka.khandge/32/35989_2.png) [@Priyanka.Khandge](https://forum.inductiveautomation.com/u/Priyanka.Khandge)\
**Post date:** [July 19, 2023, 1:16pm UTC](https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102/5 "2023-07-19T13:16:14Z")

</div>

Updated header using the list and also this script is written in the same visionWindowOpened event handler (see below screenshot).

```auto
def columnLabeler(alarmStatusTable):
    lstCustomHeaders = ['Active Time','Current State','Tag Name','Description','Alarm State','Priority','Events','Ack By','Ack Notes']
    if alarmStatusTable.componentCount > 0:
        for table in alarmStatusTable.getComponents():
            if 'AlarmStatusTable$1' in str(table. __class__ ):
                tableHeaders= table.getTableHeader()
                columnModel = table.getColumnModel()
                for column in range(table.columnCount):
                    tableColumn = columnModel.getColumn(column)
                    custColName = lstCustomHeaders[column]
                    tableColumn.setHeaderValue(str(custColName))
                    

                tableHeaders.repaint()
            columnLabeler(table)
alarmStatusTable = system.gui.getParentWindow(event).getComponentForPath('Root Container.Alarm Status Table')
columnLabeler(alarmStatusTable)

```

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

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [July 19, 2023, 1:38pm UTC](https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102/6 "2023-07-19T13:38:15Z")

</div>

> [@Priyanka.Khandge](#):
>
> visionWindowOpened event handler

In the past, I've done many component manipulations using the internalFrameOpened event handler, but I no longer prefer this way. Presently, I prefer to call my scripts from the component they affect using the componentRunning propertyChange event handler:

**Example:**

```auto
if event.propertyName == 'componentRunning`:
	#Manipulate the component here

```

This event handler only runs once when the component is initialized, and perhaps more importantly, it can't run before the component instance exists. Personally, I've never had a problem with running component initialization scripts from internalFrameOpened, but I've seen problems of the aforementioned nature from the visionWindowOpened event handler, so I would be wary of manipulating a component in this manner from there.

---

<div class="post-metadata">

**Author:** ![Priyanka.Khandge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/priyanka.khandge/32/35989_2.png) [@Priyanka.Khandge](https://forum.inductiveautomation.com/u/Priyanka.Khandge)\
**Post date:** [July 19, 2023, 1:51pm UTC](https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102/7 "2023-07-19T13:51:40Z")

</div>

Ok, Thank you @justinedwards.jle for the information and your help.

---

<div class="post-metadata">

**Author:** ![Koussaila\_Fekroune](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@Koussaila\_Fekroune](https://forum.inductiveautomation.com/u/Koussaila_Fekroune)\
**Post date:** [July 17, 2024, 5:02pm UTC](https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102/8 "2024-07-17T17:02:42Z")

</div>

Uploading: Capture d’écran 2024-07-17 125257.png…  
where can I put my script

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [July 18, 2024, 5:57am UTC](https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102/9 "2024-07-18T05:57:52Z")

</div>

> [@Koussaila\_Fekroune](#):
>
> where can I put my script

That old script is overdue for a refactor:

```python
# Written for the propertyChange event handler of an alarm status table
# The component running event only fires once when its component is first initialized
# It won't fire in the designer unless preview mode is on prior to opening the window
if event.propertyName == 'componentRunning':
		
	# Returns the first nested component of a given class
	# container = The object containing nested components to be recursively searched
	# className = the __name__ of the class given as a string
	def findComponentOfClass(container, className):
		for component in container.components:
			if component. __class__. __name__ == className:
				return component
			else:
				foundComponent = findComponentOfClass(component, className)
				if foundComponent:
					return foundComponent
	
	# Recursively find the inner table
	innerTable = findComponentOfClass(event.source, 'AlarmStatusTable$1')
	
	# Iterate through the table columns and conditionally change the header values in some way
	columnModel = innerTable.columnModel
	for column in xrange(innerTable.columnCount):
		tableColumn = columnModel.getColumn(column)
		if tableColumn.headerValue == 'Label':
			tableColumn.headerValue = 'Custom Alarm Name'
			
	# Repaint the table header
	innerTable.tableHeader.repaint()

```

This script was written for the `propertyChange` event handler of the Alarm Status table itself. Simply _ **right click on the alarm status table** _ in the designer. Then, _ **click on "Scripting"** _ in the popup that appears, and place the script in the propertyChange event handler:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/6/d6c9b7495d6281b004c3b5cc53df51410ebc17c1.png)

**Result:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/3/03b16c13c76acb3628be9c0e5c6cfd24cc2b1e86.png)

---

<div class="post-metadata">

**Author:** ![Koussaila\_Fekroune](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@Koussaila\_Fekroune](https://forum.inductiveautomation.com/u/Koussaila_Fekroune)\
**Post date:** [July 19, 2024, 2:04pm UTC](https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102/10 "2024-07-19T14:04:56Z")

</div>

I didn’t get a good result since I want it to just display  
Active time , name and ack time

---

<div class="post-metadata">

**Author:** ![Koussaila\_Fekroune](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@Koussaila\_Fekroune](https://forum.inductiveautomation.com/u/Koussaila_Fekroune)\
**Post date:** [July 19, 2024, 2:06pm UTC](https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102/11 "2024-07-19T14:06:17Z")

</div>

![Capture d’écran 2024-07-19 100350](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/8/881e9c311beb19f8664702abfb2c6dfc9cd816b8.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [July 19, 2024, 2:12pm UTC](https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102/12 "2024-07-19T14:12:06Z")

</div>

> [@Koussaila\_Fekroune](#):
>
> want it to just display  
> Active time , name and ack time

If all you want to do is hide columns, right click on the header, and use the check boxes in the photo that appears. IIRC, this action will be remembered if done in the designer prior to save.

---

<div class="post-metadata">

**Author:** ![Koussaila\_Fekroune](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@Koussaila\_Fekroune](https://forum.inductiveautomation.com/u/Koussaila_Fekroune)\
**Post date:** [July 19, 2024, 2:16pm UTC](https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102/13 "2024-07-19T14:16:10Z")

</div>

Every time I do an update it comes back to 0 you have to check again and you will do ca for all the drive I want it to remain in default just act time ,akt time é and the name of the alarm and thank you for ten help

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [July 20, 2024, 5:36am UTC](https://forum.inductiveautomation.com/t/customizing-alarm-status-table/61102/14 "2024-07-20T05:36:23Z")

</div>

> [@Koussaila\_Fekroune](#):
>
> I want it to remain in default just act time ,akt time é and the name of the alarm

I could be reading this wrong, but it seems like you are also wanting to hard code the starting columns at initialization?

It could be done like this:

```python
# Written for the propertyChange event handler of an alarm status table
# The component running event only fires once when its component is first initialized
# It won't fire in the designer unless preview mode is on prior to opening the window
if event.propertyName == 'componentRunning':
	# Returns the first nested component of a given class
	# container = The object containing nested components to be recursively searched
	# className = the __name__ of the class given as a string
	def findComponentOfClass(container, className):
		for component in container.components:
			if component. __class__. __name__ == className:
				return component
			else:
				foundComponent = findComponentOfClass(component, className)
				if foundComponent:
					return foundComponent
	
	# Recursively find the inner table
	innerTable = findComponentOfClass(event.source, 'AlarmStatusTable$1')
	
	# Alarm Status Table column model map:
	# Model Index	Column Name
	# 0 ackNotes
	# 1 Ack Time
	# 2 Ack'ed By
	# 3 Active Pipeline
	# 4 Clear Pipeline
	# 5 Ack Pipeline
	# 6 Active Time
	# 7 Clear Time
	# 8 Event Value
	# 9 Deadband
	# 10	Display Path
	# 11	Acked?
	# 12	Active?
	# 13	Clear?
	# 14	Name
	# 15	Notes
	# 16	Priority
	# 17	Source Path
	# 18	Current State
	# 19	Event ID
	# 20	Unacknowledged Duration
	# 21	Active Duration
	# 22	Label

	# Define which columns to keep (see map)
	startingColumns = [1, 6, 22]
	
	# Unhide all of the columns
	innerTable.model.fireTableStructureChanged()
	
	# Get all of the columns from the column model that are not in the starting column list
	# ...and remove them
	columnModel = innerTable.columnModel
	columnsToHide = [columnModel.getColumn(index) for index in xrange(23) if index not in startingColumns]
	for column in columnsToHide:
		columnModel.removeColumn(column)

	# Iterate through the starting columns and customize the names as needed
	for column in xrange(innerTable.columnCount):
		tableColumn = innerTable.columnModel.getColumn(column)
		if tableColumn.headerValue == 'Label':
			tableColumn.headerValue = 'Alarm Name'
	innerTable.tableHeader.repaint()

```
