Id Name Birthday Status
21 Ebony Bass Temple 15. 9. 1956 inactive
22 Uptight Unicorn 24. 4. 1998 deleted
23 Inbred Blood Conspiracy 23. 3. 1960 active
24 Real Thunder Saga 6. 12. 1940 inactive
25 Hungry Hummingbird 15. 12. 1976 active
26 Good Goose 23. 4. 1939 inactive
27 Unusual Unicorn 28. 4. 1939 active
28 Aggressive Angelfish 12. 3. 1951 deleted
29 Beautiful Boar 7. 7. 1987 deleted
30 Go Go Pogo All-Stars 10. 5. 2000 deleted
31 Rock 'n' Roll Metal Assassins 21. 3. 1966 deleted
32 Dr. Spelunking Kingdom 18. 9. 1999 active
33 Amused Alpaca 6. 8. 1941 active
34 World of Bubble Gone Wild 11. 10. 1969 deleted
35 Delightful Dove 3. 4. 1989 deleted
36 Anxious Ant 27. 10. 1986 active
37 Big-Time Chef Blast 25. 5. 1970 active
38 Rural Chocobo Journey 6. 1. 1989 deleted
39 Dynamite Go-Kart Superstar 17. 4. 1951 deleted
40 Sonic Monster of Magic 13. 2. 1963 active
( Items: 21 - 40 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;
}