877-GRID-666 24/7 online support 324 10TH ST STE 203 OAKLAND CA 94607, USA

set_col_currency()

  • Parameter(s):
    • $col_name: column name
    • $prefix: currency prefix. The default is USD symbol, $
    • $suffix: currency suffix. The default is blank.
    • $thousandsSeparator: The character as the thousands separator. The default is the comma character “,”.
    • $decimalSeparator: The character as the decimal separator. The default is the dot character.
    • $decimalPlaces: The number of digital is displayed after the decimal point. The default is two.
    • $defaultValue: The value display when the value return from database is null or empty string. The default is 0.00
  • Description:
    • This is helper method to display currency value. It formats column as currency when displayed. The value is automatically unformatted during CRUD operations.
  • Example:
1
$dg -> set_col_currency("price", "EUR", "", ",", 2, "0.00");

How to enter comma as decimal separator during data entry

The function set_col_currency() is a specialized formatter for displaying currency only. During data entry, it is still required to use the dot/period symbol is as the decimal separator.

To allow some countries that use a comma (,) instead of decimal to indicate that separation, a common workaround is replacing “,” with “.” as soon as “,” is entered during data entry using jqGridAddEditAfterShowForm event handler that evokes onkeyup javascript keyboard event.

1
2
3
4
5
6
$afterShowForm = <<<AFTERSHOWFORM
function (){
    $("#MSRP").attr("onkeyup","replacekomma()");
}
AFTERSHOWFORM
;
$dg->add_event("jqGridAddEditAfterShowForm", $afterShowForm);