Exemple #1
0
 protected function createComponentTable()
 {
     $admin = new AdminGrid($this->layoutRepository);
     // columns
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $table->addColumnText('name', 'Name')->setSortable()->setFilterText()->setSuggestion();
     $table->getColumn('name')->getCellPrototype()->width = '60%';
     $table->addColumnText('file', 'File')->setSortable()->setFilterText()->setSuggestion();
     $table->getColumn('file')->getCellPrototype()->width = '40%';
     // actions
     if ($this->isAuthorized('edit')) {
         $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax';
         $table->addAction('elements', 'Elements')->getElementPrototype()->class[] = 'ajax';
         $form = $admin->createForm($this->layoutFormFactory, 'Layout');
         $admin->connectFormWithAction($form, $table->getAction('edit'));
         // Toolbar
         $toolbar = $admin->getNavbar();
         $toolbar->addSection('new', 'Create', 'file');
         $admin->connectFormWithNavbar($form, $toolbar->getSection('new'));
         $admin->connectActionWithFloor($table->getAction('elements'), $this['elementTable'], 'Borec');
     }
     if ($this->isAuthorized('remove')) {
         $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax';
         $admin->connectActionAsDelete($table->getAction('delete'));
     }
     return $admin;
 }