I am using button to add/delete rows in Table in Perspective.
I am using code below but its not working
data = self.getSibling("Table").props. Data
newRow = {'EQUIP_NOS': '', 'EQUIP_NAME': '', 'EQUIP_STATUS':'','PLANT_SECTION':'', 'SCHEDULE_TYPE':'', 'OPERATOR':''}
data.append(newRow)
self.getSibling("Table").props. Data = data
I am getting error
File "function:runAction", line 4, in runAction
AttributeError: 'com.inductiveautomation.ignition.gateway.datasourc' object has no attribute 'append'
The data type (dataset) of the dataset returned by self.getSibling("Table").props.Data has no method .append() (append is typically for a list type, which this is not). Most likely you want to use system.dataset.addRow()
By default this prop is an Object Structure, so unless there is a binding that is converting the type to a dataset it's probably not a dataset. If there is a binding to a dataset, then what really needs to be done is an update to where ever that data is being pulled from.
Thanks All,
I want add/ delete rows for table stored in Sql Lite Database
I am using name query to access Asset_Data Table which is empty now.
After using name query "SELECT * FROM Asset_Data" , i got all columns in table which i have created in Asset_Data table.
But now all are empty. So i want to add row by button then i will enter data and must be stored in table in Sql Lite Database
A word of caution. SQL Lite is not really meant for a production environment. If you are looking for a free DB you can use PostgresSQL or MongoDB. If this is intended for a production environment I would strongly recommend you get a more powerful DB package.
To add a row to the table you will need to run an Insert query.
Probably the simplest way to achieve this is to create a Named Query for the insert and then call it from the onActionPerformed event.
I would recommend naming queries in a way that lets you know what they do. For instance I see that you have named your query "query". But with out looking at the actual query there is no way of knowing what that query does. Is it selecting data, inserting data, updating data, or deleting data? What data is it working on?
Something like "getAssetData" or "selectAssetData" is a much better name. It tells the programmer what is happening without needing to know the how of it.
So in this case, you will need an Insert query to add a non existing row, so a name like "insertNewAssetData" is appropriate.
The query will look something like:
INSERT INTO Asset_Data
VALUES (value1,value2,value3,....)
NOTE: You will need a value for every column in the table. Value1 will be inserted into Column 1
Then in the buttons onActionPerformed event, configure a script action where you collect the information and then run the named query using system.db.runNamedQuery()
If you want to update an already existing row in the table, then you will need to run an UPDATE query.