Tip: Press Shift to (un)check multiple rows.
Tip: Clicking in the header row checks all rows.
Name
Surname
Country
Birthdate
Martina Trommler is 1964-10-25
Marij Rašpolić ca 1972-12-16
Lyyli Vaara fi 1963-05-05
Dýrleif Björnsdóttir it 1972-11-24
Martha Yohannes pl 1966-11-05
Amadi Onyekachukwu it 1981-07-09
Satu Tukio au 1975-03-25
Mary Black is 1994-12-15
Consuela Takens is 1993-01-20
Aaya Weerdenburg it 1970-05-04
Ormos Széll pl 1993-01-31
Hrvojka Petković fi 1962-09-30

Code

# GroupActionGrid.php


class GroupActionGrid extends BaseGrid
{

	/** @return void */
	protected function build()
	{
		parent::build();

		$this->setPrimaryKey('id');
		$this->addColumn('firstname', 'Name');
		$this->addColumn('surname', 'Surname');
		$this->addColumn('country_code', 'Country');
		$this->addColumn('birthday', 'Birthdate');

		$this->addGroupAction('export', 'Export', [$this, 'exportMany']);

		$this->addGroupAction('delete', 'Delete', [$this, 'deleteMany'])
			->setConfirmation('Do you really want to delete all chosen items?');

		$this->setDataLoader([$this, 'dataLoader']);
	}


	/**
	 * @param  GroupActionGrid $grid
	 * @param  array $filters
	 * @param  array $order
	 * @return Nette\Database\Table\Selection
	 */
	public function dataLoader(GroupActionGrid $grid, array $filters, array $order)
	{
		return $this->database->table('user')
			->limit(12);
	}


	/**
	 * @param  Nette\Database\Table\ActiveRow[]
	 * @return void
	 */
	public function exportMany(array $records)
	{
		$ids = [];
		foreach ($records as $record) {
			$ids[] = $record->id;
		}

		$this->flashMessage('[DEMO] Exporting items ' . Nette\Utils\Json::encode($ids), 'success');
	}


	/**
	 * @param  Nette\Database\Table\ActiveRow[]
	 * @return void
	 */
	public function deleteMany(array $records)
	{
		$ids = [];
		foreach ($records as $record) {
			$ids[] = $record->id;
		}

		$this->flashMessage('[DEMO] Deleting items ' . Nette\Utils\Json::encode($ids), 'success');
	}

}
	

# BaseGrid.php


use Nette\Http\Session as NSession;
use Nette\Database\Context as NdbContext;


abstract class BaseGrid extends TwiGrid\DataGrid
{

	/** @var NdbContext */
	protected $database;


	/**
	 * @param  NSession $session
	 * @param  NdbContext $database
	 */
	public function __construct(NSession $session, NdbContext $database)
	{
		parent::__construct($session);
		$this->database = $database;
	}


	/** @return void */
	protected function build()
	{
		parent::build();
		$this->setRecordVariable('user');
	}

}