Skip to content

Display data from other columns with customer formatter

You will need custom formatter to manipulate column to add other data. It is achieved using column property function.

The example below demonstrates concatenating first and last name as full name displayed inside firstName column . 

$dg = new C_DataGrid("SELECT firstName, lastName, age FROM table1", "id", "table1");

$dg->set_col_property('firstName', array('formatter'=>'###nameFormatter###')); // must have ###


<script type="text/javascript">
function(cellvalue, options, rowObject){
    return rowObject["firstName"] + ' ' + rowObject["lastName"];

Mind you that a custom column is not editable. 

This function is extremely versatile. You will fall in love with set_col_property and use it extensively.

Feedback and Knowledge Base