Id Name Birthday Status
201 Crazy Copperhead 1. 7. 1978 deleted
202 Smiling Shark 11. 2. 1950 inactive
203 Amused Ape 10. 6. 1996 active
204 Concerned Cow 9. 7. 1989 deleted
205 Worrisome Wren 22. 5. 1953 inactive
206 Romantic Chocobo Preacher 19. 10. 1987 active
207 Inappropriate Pinball - The Gathering Storm 26. 9. 1992 active
208 World of Graveyard Explosion 14. 8. 1986 active
209 Revenge of the Math Saloon 21. 11. 1958 inactive
210 Search for the Bowling Slaughter 19. 3. 1987 deleted
211 Bewildering Amish Train 20. 2. 1995 active
212 Thoughtless Thrush 20. 12. 1972 deleted
213 Atomic STD Rush 3. 6. 1985 inactive
214 Virtua Architecture Squadron 7. 9. 1998 deleted
215 Wicked Wasp 7. 10. 1942 inactive
216 Vast Vulture 25. 12. 1986 inactive
217 Yucky Yak 23. 8. 1938 deleted
218 Hindu Wheelchair City 17. 10. 1995 inactive
219 Foolish Fly 6. 2. 1968 deleted
220 Homely Hornet 14. 12. 1950 inactive
( Items: 201 - 220 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;
}