@amy.thompson, thank you for the explanation. Below are my scripts which I developed accordingly (also thanks to this article).
View > DateTimeInput > value > Edit Change Script:
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:
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:
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")