# Perspective Table column render to view must set Field?

**URL:** <https://forum.inductiveautomation.com/t/perspective-table-column-render-to-view-must-set-field/91713>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 12, 2024, 2:23am UTC](https://forum.inductiveautomation.com/t/perspective-table-column-render-to-view-must-set-field/91713 "2024-06-12T02:23:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![taohongyu88](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@taohongyu88](https://forum.inductiveautomation.com/u/taohongyu88)\
**Post date:** [June 12, 2024, 2:23am UTC](https://forum.inductiveautomation.com/t/perspective-table-column-render-to-view-must-set-field/91713/1 "2024-06-12T02:23:56Z")

</div>

Perspective Table, I want to add a column to show icon, then click open a popup.

 ![584e39d82c88c1798816a51e23ec62f](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/5/353de146dda78a1aed46bd9802afe4a5e9d25977.png)

I set the column render to view, then set viewpath, but I find I must set the Field of the column.

So I have to add a field to the column.

 ![10653c73da465604cd94bcdcf9255c9](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/9/8916f65e6bd04cc5820fe7bfda490e6ef3b9ddd3.png)

Is there any other function, I needn't add in sql of `id as edit` ,this field to the column?  
`sqlStr='''select id,pno,startDT,endDT,processname,id as edit from pc order by id desc limit 1000'''`

---

<div class="post-metadata">

**Author:** ![amy.sudibyo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amy.sudibyo/32/38659_2.png) [@amy.sudibyo](https://forum.inductiveautomation.com/u/amy.sudibyo)\
**Post date:** [June 12, 2024, 4:10am UTC](https://forum.inductiveautomation.com/t/perspective-table-column-render-to-view-must-set-field/91713/2 "2024-06-12T04:10:08Z")

</div>

You could take the dataset output from your query and add a column of blank values to create a new dataset to feed your table. Although if this is just a dummy column where the values don't matter then I can't see any issue with the method you are already using.

I'm wondering why you are doing this in a message handler? You should make this query a named query and use a named query binding on your table. The message handler script should just be triggering a .refreshBinding on the table.

---

<div class="post-metadata">

**Author:** ![taohongyu88](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@taohongyu88](https://forum.inductiveautomation.com/u/taohongyu88)\
**Post date:** [June 12, 2024, 5:21am UTC](https://forum.inductiveautomation.com/t/perspective-table-column-render-to-view-must-set-field/91713/3 "2024-06-12T05:21:39Z")

</div>

> [@amy.sudibyo](#):
>
> You could take the dataset output from your query and add a column of blank values to create a new dataset to feed your table. Although if this is just a dummy column where the values don't matter then I can't see any issue with the method you are already using.
> 
> I'm wondering why you are doing this in a message handler? You should make this query a named query and use a named query binding on your table. The message handler script should just be triggering a .refreshBinding on the table

Because when I edit the result, I have to select again.  
So I set it in message handler.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/4/2444278d000e8dbfcce37efd810f83c8162a3231.png)

message handler

---

<div class="post-metadata">

**Author:** ![taohongyu88](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@taohongyu88](https://forum.inductiveautomation.com/u/taohongyu88)\
**Post date:** [June 12, 2024, 5:53am UTC](https://forum.inductiveautomation.com/t/perspective-table-column-render-to-view-must-set-field/91713/4 "2024-06-12T05:53:24Z")

</div>

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

```python
	# add edit , annatation column 
	colCount_editCol = table.getColumnCount()
	columnName_editCol = "editCol"
	columnData_editCol = []
	for i in range(table.getRowCount()):
		columnData_editCol.append(i)
	dataset_editCol = system.dataset.addColumn(table, colCount_editCol, columnData_editCol, columnName_editCol, int)
	
	colCount_noteCol = dataset_editCol.getColumnCount()
	columnName_noteCol = "noteCol"
	columnData_noteCol = []
	for i in range(dataset_editCol.getRowCount()):
		columnData_noteCol.append(i)
	dataset_noteCol = system.dataset.addColumn(dataset_editCol, colCount_noteCol, columnData_noteCol, columnName_noteCol, int)
	
	self.props.data=dataset_noteCol

```

Even though they are useless columns, I have to add them.  
Then I set columns -Field to them.  
I'm not sure is there other good advice？

---

<div class="post-metadata">

**Author:** ![amy.sudibyo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amy.sudibyo/32/38659_2.png) [@amy.sudibyo](https://forum.inductiveautomation.com/u/amy.sudibyo)\
**Post date:** [June 12, 2024, 6:24am UTC](https://forum.inductiveautomation.com/t/perspective-table-column-render-to-view-must-set-field/91713/5 "2024-06-12T06:24:15Z")

</div>

If you want the edit and note buttons embedded in the table then yes the table dataset needs to have those columns.

Instead of having them embedded in the table you could have those buttons outside the table. Select a row in the table before clicking one of the buttons and pass in the data from the selected table row into the button action.

---

<div class="post-metadata">

**Author:** ![taohongyu88](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@taohongyu88](https://forum.inductiveautomation.com/u/taohongyu88)\
**Post date:** [June 12, 2024, 6:33am UTC](https://forum.inductiveautomation.com/t/perspective-table-column-render-to-view-must-set-field/91713/6 "2024-06-12T06:33:21Z")

</div>

> [@amy.sudibyo](#):
>
> Select a row

But I didn't find the Row Select Events?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [June 12, 2024, 9:04am UTC](https://forum.inductiveautomation.com/t/perspective-table-column-render-to-view-must-set-field/91713/7 "2024-06-12T09:04:50Z")

</div>

> **[Perspective - Table | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/components/perspective-components/perspective-display-palette/perspective-table#selection-properties)**
>
> The Table component displays database data in tabular form.

you can see if there is something selected, you can use this value for your button external button
