How to use

TIP Can use bridge for your framework see: mesour/bridges-*

First create Mesour\UI\Application instance

$application = new Mesour\UI\Application;
Important Set request for $application
$application->setRequest($_REQUEST);

And run

$application->run();

As next create some Mesour\DataGrid\Sources\IGridSource instance

*For example Mesour\DataGrid\Sources\ArrayGridSource

$data = [
    ['id' => 1, 'name' => 'John', 'amount' => 1546],
    ['id' => 2, 'name' => 'Peter', 'amount' => 351],
    ['id' => 3, 'name' => 'Peter', 'amount' => 351],
];
// users = table name, id = primary key
$source = new Mesour\DataGrid\Sources\ArrayGridSource('users, 'id', $data);

Create Mesour\UI\DataGrid instance

For example with name basicDataGrid and set $application as parent for DataGrid component

$grid = new Mesour\UI\DataGrid('basicDataGrid', $application);

Set $source

$grid->setSource($source);

Set some columns

$grid->addText('id', '#');

$grid->addText('name', 'Name');

$grid->addNumber('amount', 'Amount')
    ->setUnit('USD') // defaults = NULL
    ->setThousandsSeparator(',') // defaults
    ->setDecimals(2) // defaults = 0
    ->setDecimalPoint('.'); // defaults

And render it

$grid->render();

Demo


#NameAmount
1John1,546.00 USD
2Peter351.00 USD
3Peter351.00 USD