- $col_name: Datagrid column name
- $format: The format types are:
- custom formatter *
- $formatoptions: PHP array stores format options of different formatting.
- Although this method is purely for cosmetic purpose, it is very useful and also practical in many situations when displaying different type of data.
- Depending on the type of format, it could have different format options. In most cases, users only need to set column formatting for “integer”, “number”, and “mail” using this method. For “currency’, “link”, and “showlink” formats, phpGrid provides a number of helper functions to make formatting simpler and easier. They are
- The helper functions will be covered later in the documentation.
- For type “date”, users don’t have to do anything for formatting. The format is automatically set to “date” when the database data field type is date or datetime.
- In addition, the formats are automatically set as “checkbox” or “select” if the edit type is checkbox or select defined in set_col_edittype().
- Though all of the formattings can be done in this method, it is recommended to use helper functions whenever possible. phpGrid ensures the formatting is automated as much as possible. Automation means less coding, and thus less room for error. Simplicity is what phpGrid strives for.
$dg -> set_col_format('quantity','integer', array('thousandsSeparator'=>',', 'defaultValue'=>'0'));
$dg -> set_col_format("emailAddress", "email");
$dg -> set_col_format("weight", 'number', array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2', "defaultValue" => '0.00'));