Group actions:
Id Name Inserted Action
1 6r0xliyalt 6. 2. 2015
2 ozl4gy9udu 6. 2. 2015
3 9i20xsrese 6. 2. 2015
4 yk95ak88ra 6. 2. 2015
5 2loxs05egs 6. 2. 2015
6 wzrdlu2o0v 6. 2. 2015
7 401nd5xv80 6. 2. 2015
8 qeba0t2ovv 6. 2. 2015
9 el25id2emd 6. 2. 2015
10 vmkppicf1z 6. 2. 2015
( Items: 1 - 10 from 200 )

Show me the code of this datagrid

public function createComponentRowConditionsGrid($name)
{
	/**
	 * @var Ublaboo\DataGrid\DataGrid
	 */
	$grid = new DataGrid($this, $name);

	$grid->setDataSource($this->ndb->table('ublaboo_example'));

	$grid->setRowCallback(function($item, $tr) {
		$tr->addClass('super-' . $item->id);
	});

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

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

	$grid->addColumnDateTime('inserted', 'Inserted');

	/**
	 * Actions
	 */
	$grid->addAction('detail', '', 'this')
		->setIcon('sun-o')
		->setTitle('Detail');

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

	/**
	 * Group action
	 */
	$grid->addGroupAction('Change order status', $this->group_statuses)->onSelect[] = [$this, 'groupChangeStatus'];

	$grid->addGroupAction('Send', [
		'john'  => 'John',
		'joe'   => 'Joe',
		'frank' => 'Frank',
	])->onSelect[] = [$this, 'groupSend'];

	$grid->addGroupAction('Delete')->onSelect[] = [$this, 'deleteMany'];

	/**
	 * Row conditions
	 */
	$grid->allowRowsGroupAction(function($item) {
		return $item->id % 2;
	});

	$grid->allowRowsAction('delete', function($item) {
		return $item->id % 3 == 0;
	});

	$grid->allowRowsAction('detail', function($item) {
		return $item->id % 4 == 0;
	});
}

Row

Row conditions

Allow Group Action

Now all rows have to provide group action or editing. Or some other of your actions. You can forbid group acitons rendering for some items like this:

$grid->allowRowsGroupAction(function($item) {
	return $item->id != 2;
});

Allow Inline Edit

Also inline editing cound be disabled for some rows:

$grid->allowRowsInlineEdit(function($item) {
	return $item->role == 'admin';
});

Allow Actions

It works simalary when you want to allow actions for just some of your items:

$grid->allowRowsAction('delete', function($item) {
	return $item->id != 3;
});

Allow Action of MultiAction

In case you need to show user just some actions in MultiAction list:

$grid->addMultiAction('goto', 'Go to')
	->addAction('profile', 'Profile', 'Profile:default')
	->addAction('settings', 'Settings', 'Settings:default')
	->addAction('homepage', 'Homepage', 'Homepage:default');

$grid->allowRowsMultiAction('goto', 'profile', function($item) { return $item->canDispleyProfile(); });
$grid->allowRowsMultiAction('goto', 'settings', function($item) { return $item->canDispleySettings(); });

Row callback

If you want to alter table row class, you can do this with row callback:

$grid->setRowCallback(function($item, $tr) {
	$tr->addClass('super-' . $item->id);
});

If you look at the example above, you will see that each row (<tr>) has class super-<id>.

Tento web používá k poskytování služeb a analýze návštěvnosti soubory cookie. Používáním tohoto webu s tím souhlasíte. V pořádku Další informace