Id Name Birthday Status
1 001 sss 12. 6. 2024 active
1 002 moje 12. 6. 2024 active
1 003 tvoje 12. 6. 2024 active
1 004 xxx 12. 6. 2024 active
1 005 Ahoj! 12. 6. 2024 active
1 006 Ahoj click 12. 6. 2024 active
1 007 111 12. 6. 2024 active
1 008 tesa111 12. 6. 2024 active
1 009 Klikam na enter 12. 6. 2024 active
1 010 klikam na enter22222222 12. 6. 2024 active
1 011 lplplpl 2. 7. 2024 active
1 012 fdsfsd 5. 7. 2024 active
1 013 Nová položka 2. 8. 2024 inactive
1 014 Ccv 10. 9. 2024 deleted
1 015 Ccv 10. 9. 2024 deleted
1 016 ASD 16. 9. 2024 active
1 017 jjj 24. 9. 2024 active
1 018 adsfadsf 26. 9. 2024 active
1 019 testUser 29. 9. 2024 active
1 020 fghggf 16. 11. 2024 inactive
( Items: 1001 - 1020 from 1020 )
  See the code below 👇 or see GitHub
public function createComponentGrid(): DataGrid
{
	$grid = new DataGrid();

	$grid->setDataSource($this->dibiConnection->select('*')->from('users'));

	$grid->setItemsPerPageList([20, 50, 100]);

	$grid->addColumnNumber('id', 'Id')
		->setAlign('start')
		->setSortable();

	$grid->addColumnText('name', 'Name')
		->setSortable()
		->setFilterText();

	$grid->addColumnDateTime('birth_date', 'Birthday');

	$grid->addColumnText('status', 'Status');

	$grid->addExportCallback('Dump to ajax rq', function (array $rows, DataGrid $grid): void {
		echo 'All fetched data were passed to export callback. Size of data: ';
		echo count($rows);
		die;
	})->setAjax();

	$grid->addExportCsvFiltered('Csv export (filtered)', 'examples.csv')
		->setTitle('Csv export (filtered)');

	$columnName = new ColumnText($grid, 'name', 'name', 'Name');
	$columnEven = (new ColumnText($grid, 'even', 'even', 'Even ID (yes/no)'))
		->setRenderer(
			fn ($item) => $item['id'] % 2 === 0 ? 'No' : 'Yes'
		);

	$grid->addExportCsv('Csv export', 'examples-all.csv')
		->setTitle('Csv export')
		->setColumns([
			$columnName,
			$columnEven,
		]);

	return $grid;
}