Пример #1
0
$groupStructure->addNumber('id');
$groupStructure->addText('name');
$groupStructure->addEnum('type')->addValue('first')->addValue('second');
$dataStrucutre = $source->getDataStructure();
$source->joinField('group', 'group_id', 'name', 'group_name');
$dataStrucutre->addDate('last_login');
$dataStrucutre->addDate('timestamp');
$dataStrucutre->addManyToOne('group', 'group', 'group_id', '{name} ({type})');
$currentUserRole = 'registered';
// create application
$application = new \Mesour\UI\Application('mesourapp');
$application->setRequest($_REQUEST);
$application->setUserRole($currentUserRole);
$application->run();
// authorizator settings
$auth = $application->getAuthorizator();
$auth->addRole('guest');
$auth->addRole('registered', 'guest');
$auth->addResource('menu');
$auth->allow('guest', 'menu', ['first', 'second']);
$auth->allow('registered', 'menu');
$auth->deny('registered', 'menu', 'second');
$grid = new \Mesour\UI\DataGrid('basicDataGrid', $application);
$wrapper = $grid->getWrapperPrototype();
$wrapper->class('my-class');
// TRUE = append
$wrapper->class('my-next-class', true);
$grid->setSource($source);
$pager = $grid->enablePager(8);
$filter = $grid->enableFilter();
$selection = $grid->enableRowSelection();