The column formatter method can be a very powerful solution to a very common need. The need is to customize the output for a cell in the grid such as a link for a form element. This can be easily done by specifying a "callback" function. This function will then return the string that is needed to be printed.
Example 62-1. Using the column formatter
Each callback function needs to accept at least one parameter ($params in the example above). This parameter will contain various information:
'record': An array containing the complete current record
'fieldName': The field name of the current column
'columnName': The column name of the current column
'orderBy': The 'orderBy' argument of the current column
'attribs': The attributes of the current column
'currRow': The number of the current row
'currCol': The number of the current column
An optional second parameter ($args in the example) allows you to pass additional information to the callback functions. In the example above, an array with length information is passed when the callback function printDesc() is called for the description column. Please note that this second parameter is only passed when you specify something in the column constructor. Therefore, it is a good practice to use $args = array() in the parameter list of your callback functions.