Formatter supports advanced formatting of the contents of cells in form, in-line and cell editing.
Formatter can be used in either of two ways: Predefined and Custom.
Here we describe the predefined formatters.

Default formatting functions are defined in the language files e.g., grid.locale-xx (where xx is your language). That mean that these formatter options are loaded when the grid java script files are loaded. See here

The default formatter options are different for different language files.

In the language file you will find all the settings that you may want to review or change before using the predefined formats. These settings can also be overridden for specific columns using the formatoptions parameter in colModel.

The second step is to set the desired formatting in colModel. This is done using the option formatter. For example.

<?php
....
$grid->setColModel(...);
$grid->setColProperty('somefield',array("formatter"=>"number"));
...

$grid->renderGrid(...);
...
?>

will format the contents of the 'somefield' column according to the rules set for 'number' in the active language file. For example, if the source value is 1234.1, then the value that actually will be put in the grid will be 1 234.10 using the options above.

Column Specific Options

Formatter options can be defined for particular columns, overwriting the defaults from the language file. This is accomplished by using the formatoptions array in colModel. For example:

<?php
....
$grid->setColModel(...);
$grid->setColProperty('somefield',array("formatter"=>"currency", "formatoptions"=>array("prefix"=>"$ ")));
...

$grid->renderGrid(...);
...
?>

This definition will overwrite the default one from the language file. In formatoptions should be placed values appropriate for the particular format type

All predefined types are compatible with the editing modules. This means that the numbers, links, e-mails, etc., are converted so that they can be edited correctly.

Below is a list of the predefined format types

Type

Options

Description

integer

thousandsSeparator,
defaulValue

thousandsSeparator determines the separator for the thousands, defaultValue set the default value if nothing in the data

number

decimalSeparator,
thousandsSeparator,
decimalPlaces,
defaulValue

thousandsSeparator determines the separator for the thousands, decimalSeparator determines the separator for the decimals, decimalPlaces determine how many decimal places we should have for the number, defaultValue set the default value if nothing in the data

currency

decimalSeparator,
thousandsSeparator,
decimalPlaces,
defaulValue,
prefix,
suffix

The same as number, but we add aditional two options - prefix a text the is puted before the number and suffix the text that is added after the number

date

srcformat,
newformat

srcformat is the source format - i.e. the format of the date that should be converted, newformat is the new output format. The definition of the date format uses the PHP conversions. Also you can use a set of predefined date format - see the mask options in the default date formatting set

email

none

When a mail type is used we directly add a href with mailto: before the e-mail

link

target

The default value of the target options is null. When this options is set, we construct a link with the target property set and the cell value put in the href tag.

showlink

baseLinkUrl,
showAction,
addParam,
target,
idName

baseLinkUrl is the link.
showAction is an additional value which is added after the baseLinkUrl.
addParam is an additional parameter that can be added after the idName property.
target, if set, is added as an additional attribute.
idName is the first parameter that is added after the showAction. By default, this is id,

checkbox

disabled

The default value for the disabled is true. This option determines if the checkbox can be changed. If set to false, the values in checkbox can be changed

select

none

this is not a real select but a special case. See note below