Skip to content

Deprecated since 7.2

This page documents the classic module layer (CBController and cbInit()). It still works in every 7.x release, but new code should use resources and pages.

Use instead: TextColumn::make('price')->numeric(2) or ->money('$').

How To Put Number Format at Grid Data Column ​

Table : Products ​

Field NameData Type
idint (PK)
namevarchar(255)
pricedouble

Products ​

php
$this->col[] = ["label"=>"Name","name"=>"name"];
$this->col[] = ["label"=>"Price","name"=>"price","callback_php"=>'number_format($row->price)';

or

php
$this->col[] = ["label"=>"Name","name"=>"name"];
$this->col[] = ["label"=>"Price","name"=>"price","callback_php"=>'number_format([price])';

You can see we use callback_php . One think that you need to remember, don't use double quote instead use single quote.

What's Next ​

Table Of Contents ​

Released under the MIT License.