Id Jméno Vloženo
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
( Položky: 1 - 10 z 200 )

Show me the code of this datagrid

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

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

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

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

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

	/**
	 * Localization
	 */
	$translator = new Ublaboo\DataGrid\Localization\SimpleTranslator([
		'ublaboo_datagrid.no_item_found_reset' => 'Žádné položky nenalezeny. Filtr můžete vynulovat',
		'ublaboo_datagrid.no_item_found' => 'Žádné položky nenalezeny.',
		'ublaboo_datagrid.here' => 'zde',
		'ublaboo_datagrid.items' => 'Položky',
		'ublaboo_datagrid.all' => 'všechny',
		'ublaboo_datagrid.from' => 'z',
		'ublaboo_datagrid.reset_filter' => 'Resetovat filtr',
		'ublaboo_datagrid.group_actions' => 'Hromadné akce',
		'ublaboo_datagrid.show_all_columns' => 'Zobrazit všechny sloupce',
		'ublaboo_datagrid.hide_column' => 'Skrýt sloupec',
		'ublaboo_datagrid.action' => 'Akce',
		'ublaboo_datagrid.previous' => 'Předchozí',
		'ublaboo_datagrid.next' => 'Další',
		'ublaboo_datagrid.choose' => 'Vyberte',
		'ublaboo_datagrid.execute' => 'Provést',

		'Name' => 'Jméno',
		'Inserted' => 'Vloženo'
	]);
	$grid->setTranslator($translator);
}

Localization

As you can see in the example above, a SimpleTranslator class comes with this datagrid (example was translated to czech). You can use it as shown (you will do that probably in some factory for all datagrids in your application). Of course you can use your own translator - it just has to implement Nette\Localization\ITranslator.

Filters localization

All filters and their placeholders are translated normally except for FilterSelect and FilterMultiSelect - options of select box are not being translated!

You can change that behaviour:

$grid->addFilterMultiSelect('status', 'Status:', [
	0 => 'Offline',
	1 => 'Online',
	2 => 'Standby'
])->setTranslateOptions(); // Or disable it again: ::setTranslateOptions(FALSE)
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