Id Name Link Status Action
141 Silent Harpoon Saloon
142 Adventurous Aardvark
143 Disney Bingo - The Dark Project
144 Unsightly Unicorn
145 Prickly Parrot
146 Colorful Corncrake
147 Distinguished Bungie in the Middle East
148 Sinister Banana Interactive
149 Shrunken Dentist Preacher
150 Everybody Hates the Dungeon Massacre
151 Enchanting Eland
152 Obedient Ostrich
153 Surprise Afro Palace
154 Homeless Hedgehog
155 Unforgettable Bazooka Revisited
156 Better Badger
157 Religious Trailer Park EX
158 Quiet Cyborg Smash
159 Crazy Capuchin
160 Fragile Flamingo
( Items: 141 - 160 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')
		->setSortable()
		->setAlign('start');

	$grid->addColumnText('name', 'Name')
		->setSortable()
		->setEditableCallback(function ($id, $value): void {
			$this->flashMessage(sprintf('Id: %s, new value: %s', $id, $value));
			$this->redrawControl('flashes');
		})->addCellAttributes(['class' => 'text-center']);

	$grid->addColumnLink('link', 'Link', 'this#demo', 'name', ['id', 'surname' => 'name'])
		->setEditableValueCallback(
			fn (Row $row) => $row['name']
		)
		->setEditableCallback(function ($id, $value): string {
			$this->flashMessage(sprintf('Id: %s, new value: %s', $id, $value));
			$this->redrawControl('flashes');

			$link = Html::el('a')
				->href($this->link('this#demo', ['id' => $id]))
				->setText($value);

			return (string) $link;
		})->addCellAttributes(['class' => 'text-center']);

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

	$inlineEdit = $grid->addInlineEdit();

	$inlineEdit->onControlAdd[] = function ($container): void {
		$container->addText('name', '')
			->setRequired('aaa');
		$container->addText('birth_date', '');
		$container->addText('link', '');
		$container->addSelect('status', '', [
			'active' => 'Active',
			'inactive' => 'Inactive',
			'deleted' => 'Deleted',
		]);
	};

	$inlineEdit->onSetDefaults[] = function (Container $container, Row $row): void {
		$container->setDefaults([
			'id' => $row['id'],
			'name' => $row['name'],
			'birth_date' => DateTime::fromSafe($row->asDateTime('birth_date'))?->format('j. n. Y'),
			'link' => $row['name'],
			'status' => $row['status'],
		]);
	};

	$inlineEdit->onSubmit[] = function ($id, $values): void {
		$this->dibiConnection->update('users', ['name' => $values['name']])->where('id = %i', $id)->execute();
		$this->flashMessage('Record was updated!', 'success');
		$this->redrawControl('flashes');
	};

	$inlineEdit->setShowNonEditingColumns();

	return $grid;
}