# Perspective Table View Date Picker

**URL:** <https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589>\
**Category:** Ignition\
**Tags:** perspective, vision\
**Created:** [August 30, 2023, 10:15pm UTC](https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589 "2023-08-30T22:15:22Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [August 30, 2023, 10:15pm UTC](https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589/1 "2023-08-30T22:15:22Z")

</div>

In vision, when Column with date type is set to editable.  
When cell is clicked, date time picker will show.

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

Is this possible in Perspective Table?

---

<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:** [August 31, 2023, 4:44am UTC](https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589/2 "2023-08-31T04:44:44Z")

</div>

The Perspective table doesn't do this by default. To have the picker appear you would need to render the date column of your table as a view, and have an embedded view containing a date picker component.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [August 31, 2023, 1:00pm UTC](https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589/3 "2023-08-31T13:00:14Z")

</div>

Thanks for confirming that.  
So, I setup(ed) an embedded datetime picker by setting the column render property to view and view path point to datetime picker view.

But how do I return the small view output back to the "upper layer" cell?  
Or how do I bind each cell in the date picker column, to the parameter of the datetime view?

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [August 31, 2023, 3:11pm UTC](https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589/4 "2023-08-31T15:11:35Z")

</div>

So I read few forum post about Embedded View on table, but still did not manage to understand.

I have a table with one column that accept object as data (as shown below).

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/4/84f513e0a741015f65001da68781c7b232b8fb52.png)

Below shows my render settings, with one param name Date (bidirectional)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/0/2079c69e5070de82f1408143c0b9768a0702e8b2.png)

I have onEditCellCommit Script below

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/5/25b402607a4d725712d8a0f33af0ce8209abf1ac.png)

On testing, the script does not get triggered..  
How do I make the onEditCellCommit triggered? and Event.value bind to Date Param of View?

Am I on the right path?

---

<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:** [August 31, 2023, 11:05pm UTC](https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589/5 "2023-08-31T23:05:29Z")

</div>

Rather than an on cell commit action you want to have the action on value change of your embedded view date picker.

What this action does will depend on where your table dataset is populated from. E.g. if it's a query binding you'll need to run a query to update that database, if it's a tag binding you'll need to perform a tag write.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [September 1, 2023, 3:19am UTC](https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589/6 "2023-09-01T03:19:55Z")

</div>

What? do you mean the direction of data can only go one way from table to the embedded view but cannot go from view to the table?

If I need to make the data from embedded view go back to the table, I need to go around? in this case i also need to give the cell location into the embedded view so it knows which data it is?

Sorry, I thought it was a bit straight forward than the above.

This makes sense, as this is same strategy with flex repeater.

---

<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:** [September 1, 2023, 4:10am UTC](https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589/7 "2023-09-01T04:10:38Z")

</div>

You can certainly send the value from the view back to the table, but all this does is update the value displayed in your table. _It doesn't update the underlying data that is populating your table._ To be clear, this would also be the case for any data in your table, whether you have an embedded view or not.

For example, let's say you have a table populated by a query binding. What is displayed in the table is effectively a 'copy' of the results of that query. If you edit a value in the table, you are editing what is displayed in that table. You are _not_ making any changes to the database that is providing the data to the table. If you want to update that data, you would need to run an update query. So in this example, since the value is being modified from an embedded view, the action to update the data should happen from the embedded view, rather than from the onCellCommit action from the table in the parent view.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [September 1, 2023, 12:07pm UTC](https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589/8 "2023-09-01T12:07:12Z")

</div>

Got it, I will pass row and column data to the view. (I will still figure out how to do that). Then apply value change script( if you mean property change script), use message handler, to update data on the source - in my case the table dataset is the source via dataset.setValue command.

---

<div class="post-metadata">

**Author:** ![Andrew\_Buldyzhov](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrew_buldyzhov/32/74246_2.png) [@Andrew\_Buldyzhov](https://forum.inductiveautomation.com/u/Andrew_Buldyzhov)\
**Post date:** [March 27, 2025, 9:33am UTC](https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589/9 "2025-03-27T09:33:08Z")

</div>

@amy.sudibyo, thank you for the explanation. Below are my scripts which I developed accordingly (also thanks to [this article](https://forum.inductiveautomation.com/t/table-cell-change-to-date-and-time-picker/100785)).

View \> DateTimeInput \> value \> Edit Change Script:

```python
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
		
	from java.text import SimpleDateFormat
	
	value = currentValue.value
	if (value is not None) and ('Binding' not in str(origin)):
		
		date_format = SimpleDateFormat('yyyy-MM-dd')
		formatted_date = date_format.format(value)
		rowIndex = self.view.params.rowIndex
		column = self.view.params.column
		
		msg = 'UpdateTableCell'
		payload =	{
					'value'	: formatted_date,
					'rowIndex': rowIndex,
					'column': column
					}
		system.perspective.sendMessage(msg, payload)

```

Table \> Configure Events \> onEditCellCommit:

```python
def runAction(self, event):

	msg = 'UpdateTableCell'
	payload =	{
			'value'	: event.value,
			'rowIndex': event.row,
			'column': event.column
			}
	system.perspective.sendMessage(msg, payload)

```

Table \> Configure Scripts \> Message Handlers \> UpdateTableCell:

```python
def onMessageReceived(self, payload):

	value = payload['value']
	rowIndex = payload['rowIndex']
	column = payload['column']

	dbTable=self.custom.dbTable
	id = self.props.data.getValueAt(rowIndex,'id')
	query = "UPDATE %s SET %s = '%s' WHERE id = %d" % (dbTable, column, value, id)
	system.db.runUpdateQuery(query)
#	system.perspective.print(query)
	
	self.refreshBinding("props.data")

```

---

<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:** [March 27, 2025, 10:18am UTC](https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589/10 "2025-03-27T10:18:43Z")

</div>

To avoid the SimpleDateFormat import use the built-in function, [system.date.format | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-date/system-date-format). This should give a performance improvement.

---

<div class="post-metadata">

**Author:** ![Andrew\_Buldyzhov](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrew_buldyzhov/32/74246_2.png) [@Andrew\_Buldyzhov](https://forum.inductiveautomation.com/u/Andrew_Buldyzhov)\
**Post date:** [March 27, 2025, 10:51am UTC](https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589/11 "2025-03-27T10:51:16Z")

</div>

@Transistor, thank you for the suggestion. Here's the updated script:

```python
def valueChanged(self, previousValue, currentValue, origin, missedEvents):

	value = currentValue.value
	if (value is not None) and ('Binding' not in str(origin)):

		formatted_date = system.date.format(value,'yyyy-MM-dd')
		rowIndex = self.view.params.rowIndex
		column = self.view.params.column
		
		msg = 'UpdateTableCell'
		payload =	{
					'value'	: formatted_date,
					'rowIndex': rowIndex,
					'column': column
					}
		system.perspective.sendMessage(msg, payload)

```

---

<div class="post-metadata">

**Author:** ![Andrew\_Buldyzhov](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrew_buldyzhov/32/74246_2.png) [@Andrew\_Buldyzhov](https://forum.inductiveautomation.com/u/Andrew_Buldyzhov)\
**Post date:** [March 31, 2025, 12:32pm UTC](https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589/12 "2025-03-31T12:32:03Z")

</div>

Here's a small update. The date without time is not supported by SQLite:

```python
def valueChanged(self, previousValue, currentValue, origin, missedEvents):

	value = currentValue.value
	if (value is not None) and ('Binding' not in str(origin)):

		formatted_date = system.date.format(value,'yyyy-MM-dd hh:mm:ss')
		rowIndex = self.view.params.rowIndex
		column = self.view.params.column
		
		msg = 'UpdateTableCell'
		payload =	{
					'value'	: formatted_date,
					'rowIndex': rowIndex,
					'column': column
					}
		system.perspective.sendMessage(msg, payload)

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 31, 2025, 12:36pm UTC](https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589/13 "2025-03-31T12:36:29Z")

</div>

> [@Andrew\_Buldyzhov](#):
>
> not supported by SQLite

_Psssst!_ SQLite is not designed for production use. It is designed for "read-mostly" configuration data. This particular problem should never occur in Ignition, because you should not be using SQLite.

SQLite is convenient for training and for simple testing where its limitations do not matter. Do not use it for anything else.

---

<div class="post-metadata">

**Author:** ![Andrew\_Buldyzhov](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andrew_buldyzhov/32/74246_2.png) [@Andrew\_Buldyzhov](https://forum.inductiveautomation.com/u/Andrew_Buldyzhov)\
**Post date:** [March 31, 2025, 12:42pm UTC](https://forum.inductiveautomation.com/t/perspective-table-view-date-picker/78589/14 "2025-03-31T12:42:35Z")

</div>

I use SQLite on my local environment for quick tests. So I have decided that it won't hurt if I make my query a bit more universal and explicit.
