Id Name Birthday Status
181 Underwater Donkey Princess 11. 7. 1930 deleted
182 Calm Chinchilla 27. 12. 1990 inactive
183 Bloody Bug 17. 7. 1953 deleted
184 8-Bit WWE World 6. 2. 1939 active
185 Glorious Goosander 6. 11. 1989 deleted
186 Prickly Pigeon 12. 4. 2000 active
187 Arrogant Alpaca 23. 9. 1960 deleted
188 Vast Vendace 22. 6. 1967 active
189 Frail Fly 27. 7. 1990 inactive
190 Shady Robot Inferno 13. 3. 1939 deleted
191 Real Raccoon 27. 1. 1995 deleted
192 Nasty Narwhal 20. 3. 1972 deleted
193 Old-fashioned Oryx 4. 5. 1939 inactive
194 Tired Thrush 2. 7. 1976 active
195 Fisher Price Lego Romp 10. 3. 1956 inactive
196 Misty Moose 23. 12. 1990 active
197 Better Buffalo 28. 6. 1983 deleted
198 Obnoxious Otter 20. 5. 1979 deleted
199 Happy Hornet 23. 8. 1976 active
200 Itchy Ibis 28. 6. 1953 deleted
( Items: 181 - 200 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;
}