Skip to content

Displaying TIMESTAMP Fields in an Editable Grid

For fields that has TIMESTAMP data type, there are two use cases:

1. For TIMESTAMP fields do not require display, you can simply not to include the column in the SQL SELECT statement.

For example: 

e.g. timestamp_column is the TIMESTAMP field, do not include in the SELECT statement

$dg = new C_DataGrid('select id, col1, col2 from TABLE_NAME', 'id', 'TABLE_NAME');// 
$dg->enable_edit('FORM');
$dg->display();

 or hide it by calling set_col_hidden(). 

$dg = new C_DataGrid('select id, col1, col2, timestamp_column from TABLE_NAME', 'id', 'TABLE_NAME');
$dg->set_col_hidden('timestamp_column', false);
$dg->enable_edit('FORM');
$dg->display();

2. For TIMESTAMP fields require display. Here's a solution. Set the column to be read only, and must use INLINE edit mode.

$dg = new C_DataGrid('select id, col1, col2, timestamp_column from TABLE_NAME', 'id', 'TABLE_NAME');
$dg->set_col_readonly('timestamp_column');
$dg->enable_edit('INLINE');
$dg->display();


Do not use set_col_default() because the timestamp is ultimately set by the database automatically, not by the grid. 


Feedback and Knowledge Base