# How to read the cell value from the table column, which has render type as view

**URL:** <https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791>\
**Category:** General Discussion\
**Tags:** perspective\
**Created:** [December 13, 2024, 10:03am UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791 "2024-12-13T10:03:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [December 13, 2024, 10:03am UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/1 "2024-12-13T10:03:30Z")

</div>

Hi Team,  
I have table of 3 columns with filled data, 4th column I added as pseudo column from named query(no data).  
I this 4th column I want to add CheckBox/Toggle in each row. User can operates on each row and and the data will that CheckBox value on each row  
Here some Screen Shots.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/b/fba9273df32a44f9c61c5d6151b9f04b988ad518.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/2/82300d5c11ac4e6065cfa56c1c82b9124c27fc63.png)  
created Param for the template view  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/a/ba2b253e4c7293ffac816d80d235771aa639089d.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/b/6bae6fee3baadaf27283adebc4ffb476705d8671.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/f/cf5f10ba740896346e1456a17ccab54a9d0bdfda.png)  
After saving in DB I am getting NULL value, since I am not able read Toggle value.

Please suggest

---

<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:** [December 13, 2024, 12:33pm UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/2 "2024-12-13T12:33:41Z")

</div>

You don't need to embed a view for the toggle. Instead, set the boolean true or false condition in the column data, and then set the following (assuming it's column 3 we're working on):

`columns.3.field : <set to name of boolean column>`  
`columns.3.editable : true`  
`columns.3.render : boolean`  
`columns.3.boolean : toggle`

* * *

![Abnormal toggle](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/e/bed884d788ab1bef481d48912858f2878e9561ca.png)

Don't change the label of a toggle switch with the true or false value. In the image above it reads "Abnormal is off" so it's **not abnormal** (which I presume is not what you mean)! Instead, just label the column as "Normal" and it will be obvious what it means.

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [December 14, 2024, 2:49am UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/3 "2024-12-14T02:49:18Z")

</div>

Hi,  
I followed what you suggested,

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/1/111675bcd43b876945aa103ce5172f9577cea10f.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/8/68165b63bdc75c761736e4f36362e676e6b98af9.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/e/2edda3deb39c8bdfb895df23035ca3888890ab5d.png)  
Named query: SELECT \*,'' AS Status,CAST(CURRENT\_TIMESTAMP as DATETIME) AS Date\_Time,'' AS UserName FROM statusTable.  
Status column has no data. I need CheckBox in Status column, The user can select/deselect .If selected(true) I want to save it as Normal,If False Abnormal.  
Here after I selecting first row checkBox , on selecting 2nd checkBox first checkBox is changing to False.

How I make changes to save the table data in DB on clicking on SAVE button.  
output example required in Db:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/3/b367c59019ebe86c06613ee3b62dfab7a7be639e.png)

Please guide.

Thank you.

---

<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:** [December 14, 2024, 4:03pm UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/4 "2024-12-14T16:03:28Z")

</div>

You need to create an onActionPerformed event script to update the database. (Right-click on the button ...)

Tip: format your code using the \</\> button. See [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831). Then you'll get this and it will be obvious which are single and double quotes.

```python
SELECT 
    *,
    '' AS Status,
    CAST(CURRENT_TIMESTAMP as DATETIME) AS Date_Time,
    '' AS UserName 
FROM statusTable

```

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [December 14, 2024, 5:46pm UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/5 "2024-12-14T17:46:53Z")

</div>

sorry for the inconvenience.  
here I need to read the value of STATUS column which may be checkBOX/Toggle to update in DB. I tried but it is saving null value in DB.

Please guide on this.

---

<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:** [December 14, 2024, 7:45pm UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/6 "2024-12-14T19:45:20Z")

</div>

Show us your (formatted) code.

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [December 15, 2024, 7:50am UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/7 "2024-12-15T07:50:23Z")

</div>

Hi,  
Status column- need checkBOX/toggle- changed value to be saved in DB  
Below is the code I am using to save all the rows at a time on clicking on SAVE button.

```python
import system

    # Get the dataset from the Table component
    dataset = self.getSibling("Table").props.data

    # Convert the dataset to a PyDataSet for easy iteration
    pyDataset = system.dataset.toPyDataSet(dataset)

    # Define the SQL query for insertion into the target table
    query = """
    INSERT INTO [dbo].[ACTIVITYCHECLIST] (Asset_No, Activity, Maintaince_Name, Method, Time_In_Min, Special_Instruction, Frequency, Status, Date_Time, UserName)
    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    """

    # Loop through each row in the dataset
    for row in pyDataset:
        # Extract values from the dataset row based on your column names
        Asset_No = row["Asset_No"]
        Activity = row["Activity"]
        Maintaince_Name = row["Maintaince_Name"]
        Method = row["Method"]
        Time_In_Min = row["Time_In_Min"]
        Special_Instruction = row["Special_Instruction"]
        Frequency = row["Frequency"]
        Status = row["Status"] # Extract Status from the dataset directly
        Date_Time = row["Date_Time"] # Ensure this is in the proper datetime format
        UserName = row["UserName"] # Extract UserName from the dataset directly

        # Print Status and UserName for debugging purposes
        print("Status:", Status)
        print("UserName:", UserName)

        # Execute the query with the extracted values
        system.db.runPrepUpdate(query, [Asset_No, Activity, Maintaince_Name, Method, Time_In_Min, Special_Instruction, Frequency, Status, Date_Time, UserName])

```

On my Designer , below is the table:

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

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/0/109958cd720b1fe534e65381d69b27f9d191969e.png)  
I am getting null value in DB.

Db structure:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/6/66004d43c14383819dfb2c6f0d0acfe06a2f048c.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:** [December 15, 2024, 9:03am UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/8 "2024-12-15T09:03:55Z")

</div>

The table `status` column is returning a boolean. Your table `status` column is a string so I'm not sure what would happen there.

It looks like you're using MS SQL and so you should try  
`[Status] BIT`  
in the table definition instead.

> **[SQL - BOOLEAN](https://www.tutorialspoint.com/sql/sql-boolean-bit-operator.htm)**
>
> SQL - BOOLEAN - A Boolean is a universal data type which stores true or false values. It is used when we define a variable in a column of the table.

You could also simplify your code:

```python
    query = """
    INSERT INTO [dbo].[ACTIVITYCHECLIST] 
        (Asset_No, Activity, Maintaince_Name, Method, Time_In_Min, 
        Special_Instruction, Frequency, Status, Date_Time, 
        UserName)
    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    """

    for row in pyDataset:
        system.db.runPrepUpdate(query, [
            row["Asset_No"],
            row["Activity"],
            row["Maintaince_Name"],
            row["Method"],
            row["Time_In_Min"],
            row["Special_Instruction"],
            row["Frequency"],
            row["Status"], 
            row["Date_Time"] ,
            row["UserName"]
        )

```

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [December 18, 2024, 4:02am UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/9 "2024-12-18T04:02:29Z")

</div>

Hi,  
I changed the the data type of Status column into BIT. below is my SQL table.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/2/52043035e386a02ceeb02e59c5668dc190bea349.png)  
I called this table using named query. This is the Operator entry table.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/8/c8c84bccaea257677ebd27e2fc9cd04ed0cab2c6.png)  
for status column need to use check box/toggle. After changing the value in status column, I need to save the updated data into another table. I am able to save the table by using above script, but status column value is not saving. since T/F value is not sitting in the cell. same for DateTime column need to put Datepicker operator has to choose the date and update.

Thank you

---

<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:** [December 18, 2024, 10:10am UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/10 "2024-12-18T10:10:31Z")

</div>

![subToggle params](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/f/5f72bae7b11323c2481d0270906ce2ad3badbaaf.png)  
_Figure 1. Setup for subview params._  
For more on this see the bottom of [Table Column Configurations | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/components/perspective-components/perspective-display-palette/perspective-table/table-column-configurations#embedding-a-view-in-a-table-cell).

 ![subToggle onActionPerformed](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/6/0651edcbfe9b6222f0f9e2f41ed678fc829947c4.png)  
_Figure 2. On the toggle switch add a script to send a message to a message handler on the table._

Code:

```python
def runAction(self, event):
	# Pass the change back to the calling table.
	payload = {
		"row" : self.view.params.row,
		"value" : self.props.selected
	}
	system.perspective.sendMessage("statusUpdate", payload)

```

 ![subToggle message handler](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/5/d54ac99d089b89f4f6927a2b5f299ecc9036f1f3.png)  
_Figure 3. Configure a script on the table as shown._

Code:

```python
def onMessageReceived(self, payload):
	self.props.data[payload['row']].status = payload['value']

```

You'll need to do a similar job for the datepicker column.

Notes:  
You need to set your Date\_Time column field name and set the column's `render : date`.  
I see you have the word "Normal" in the Status column. I hope it doesn't change to "Abnormal" when the toggle is off. See post #2.

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [December 26, 2024, 10:24am UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/11 "2024-12-26T10:24:16Z")

</div>

Hi Team,  
I followed the same steps as guided. I am getting error while change the toggle button. But when change the dataset in Json format the value of the toggle showing correct.

```python
Error running Dashbooard/Auto_Updation_1@D/root/Table.onMessageReceived(self, payload): Traceback (most recent call last): File "<function:onMessageReceived>", line 4, in onMessageReceived TypeError: 'com.inductiveautomation.ignition.gateway.datasource.BasicStreamingDataset' object is unsubscriptable

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/9/59852efd1eafa36411f76045daf4f8bcec8bb7b1.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:** [December 26, 2024, 10:32am UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/12 "2024-12-26T10:32:50Z")

</div>

Good.  
Now, to format the Date\_Time column set,  
`columns.8.field : Date_Time` ← 1  
`columns.8.render : date`  
`columns.8.dateFormat : YYYY-MM-DD` ← or whatever you want.

1 Set the column name for all fields is usually a good idea. Many of the column properties won't work until you do.

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [December 26, 2024, 11:12am UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/13 "2024-12-26T11:12:48Z")

</div>

Thank you,  
But on clicking save button, toggle value is saving as TRUE only, changed value is not saving in DB.

| Asset\_No | Activity | Maintaince\_Name | Method | Time\_In\_Min | Special\_Instruction | Frequency | Status | Date\_Time | UserName |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| CRBO1 | All Side | Machine All side cleaning | With Cloth | 5 | Use coolant | Daily | 1 | 2024-12-19 03:50:24.983 | NULL |
| CRBO1 | All Side | Machine All side cleaning | With Cloth | 5 | Use coolant | Daily | 1 | 2024-12-19 03:50:24.983 | NULL |
| CRBO1 | All Side | Machine All side cleaning | With Cloth | 5 | Use coolant | Daily | 1 | 2024-12-19 03:50:24.983 | NULL |
| CRBO1 | All Side | Machine All side cleaning | With Cloth | 5 | Use coolant | Daily | 1 | 2024-12-19 03:50:24.983 | NULL |

---

<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:** [December 26, 2024, 12:03pm UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/14 "2024-12-26T12:03:50Z")

</div>

Can you confirm in Designer Preview Mode that the toggle switch is changing the `data.n.Status` value?

The other way to test this is to add a second table to the view and bind its `data` property to the `data` property of the first table. You should then see the effect of the Status toggle in the second table.

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [December 27, 2024, 4:07am UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/15 "2024-12-27T04:07:29Z")

</div>

Hi,

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/c/bca237d2f8064f2e157a1c839a580cee237bba19.png)  
I am changing the table T1 toggle, in table2 status not changing

---

<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:** [December 27, 2024, 9:29am UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/16 "2024-12-27T09:29:34Z")

</div>

In Designer Preview Mode, turn on Tools | Console and see if any error messages show up when you toggle one of the switches.

If that doesn't show anything then post your configuration as I have done in post #10.

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [December 27, 2024, 9:48am UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/17 "2024-12-27T09:48:09Z")

</div>

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

```python
[AWT-EventQueue-0] ERROR com.inductiveautomation.ignition.client.util.gui.ErrorUtil -- Error running Dashbooard/Auto_Updation_1 (1)@D/root/Table.onMessageReceived(self, payload): Traceback (most recent call last):
  File "<function:onMessageReceived>", line 4, in onMessageReceived
TypeError: 'com.inductiveautomation.ignition.gateway.datasource.BasicStreamingDataset' object is unsubscriptable

```

```python
self.props.data[payload['row']].Status = payload['value']

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/4/84b2e77f13f2a7f3d8fa5a495628cab970c2c2a7.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:** [December 27, 2024, 10:01am UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/18 "2024-12-27T10:01:12Z")

</div>

On line 3 of the messageHandler, try adding,  
`system.perspective.print(payload)`  
and see what shows up in Console.

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [December 27, 2024, 10:40am UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/19 "2024-12-27T10:40:26Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/2/b2e7710f0931b27e88bd1eceb0e2994c86c631ee.png)  
but on clicking save button, In DB status saving 1.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/f/bfec8c8607019cf439cf675b5ffab57051d9fa0b.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:** [December 27, 2024, 3:39pm UTC](https://forum.inductiveautomation.com/t/how-to-read-the-cell-value-from-the-table-column-which-has-render-type-as-view/99791/20 "2024-12-27T15:39:53Z")

</div>

I checked my code again and changed every occurrence of `status` to `Status` and it works both ways.

You'll need to debug. Try adding this code in your message handler at line 3:

```python
system.perspective.print("self.props.data[payload['row']]")
system.perspective.print(self.props.data[payload['row']])
system.perspective.print("payload['value']")
system.perspective.print(payload['value'])

```
