Alarms history table comments to DB


I have an alarms history table populated by queryAlertHistory, where I have Notes column enabled and editable. I would like to store entered text for corresponding alarm in the database. How is it possible?

Well, once you make the column editable you need to figure out the script that writes information back to the database on the cellEdited event of the table. When a cell is modified the cellEdited event fires letting you know:


Your script would look something like:value = event.newValue row = event.row col = event.column data = id = data.getValueAt(row, "id") if col == 1: # whatever the note column is system.db.runPrepUpdate("......", [id]) # whatever the query is INSERT or UPDATEHope that helps you get started.

So first thing I have to add Comments column to alert_log table?

And for “id = data.getValueAt(row, “id”)”,
there is no such “id” column in component “Table”, what does it stand for?

Thank you.

Right, I would recommend doing your own SQL query so you can bring back the id column. You can bind the data property of the table to a query like:SELECT id, display_path, active_timestamp, ...... FROM alert_log WHERE active_timestamp BETWEEN '2012-01-01 00:00:00' AND '2012-01-01 23:59:59' ORDER BY active_timestamp ASCYou may want to change it up a little. Let us know if you have any more questions.