Id Name Action
489 3D Amish Solid Blahblah
492 8-Bit Paintball Fiesta Blahblah
184 8-Bit WWE World Blahblah
582 A Boy and His Dog Strikes Again Blahblah
874 Adorable Addax Blahblah
645 Adorable Anteater Blahblah
142 Adventurous Aardvark Blahblah
635 Adventurous Addax Blahblah
236 Adventurous Albatross Blahblah
803 Adventurous Angelfish Blahblah
608 Adventurous Armadillo Blahblah
655 Adventurous Armadillo Blahblah
365 Aero Jetski Assault Blahblah
748 Aero Outlaw of Mystery Blahblah
242 Aero Shopping Unit Blahblah
638 Aggressive Alpaca Blahblah
28 Aggressive Angelfish Blahblah
165 Aggressive Antelope Blahblah
627 Agreeable Alligator Blahblah
338 Agreeable Ant Blahblah
( Items: 1 - 20 from 1000 )
  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->setSortable();

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

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

	$multiAction = $grid->addMultiAction('multi_blah', 'MultiAction')
		->addAction('blah', 'Blahblah', 'blah!')
		->addAction('blah2', 'Blahblah2', 'blah!', ['name']);

	$multiAction
		->getAction('blah2')
		->setIcon('check');

	$grid->addAction('blah', 'Blahblah', 'blah!')
		->setClass('btn btn-xs btn-primary ajax');

	$grid->addAction('this', '')
		->setIcon('redo')
		->setClass('btn btn-xs btn-success');

	$actionCallback = $grid->addActionCallback('custom_callback', '');

	$actionCallback
		->setIcon('sun')
		->setTitle('Hello, sun')
		->setClass('btn btn-xs btn-default btn-secondary ajax');

	$actionCallback->onClick[] = function ($itemId): void {
		$this->flashMessage('Custom callback triggered, id: ' . $itemId);
		$this->redrawControl('flashes');
	};

	$grid->addAction('delete', '', 'delete!')
		->setIcon('trash')
		->setTitle('Delete')
		->setClass('btn btn-xs btn-danger ajax')
		->setConfirmation(
			new StringConfirmation('Do you really want to delete example %s?', 'name')
		);

	$grid->addToolbarButton('this', 'Toolbar')->addAttributes(['foo' => 'bar']);
	$grid->addToolbarButton('this#2', 'Button', ['foo' => 'bar']);

	return $grid;
}