Exemplo n.º 1
0
 public function prepareViewModel(Datagrid $grid)
 {
     //parent::prepareViewModel($grid);
     $options = $this->getOptionsRenderer();
     $data = $grid->getDataSource()->getDataDetail();
     $viewModel = $this->getViewModel();
     $mcvEvent = $grid->getMvcEvent();
     $viewModel->setVariable('daterangeEnabled', false);
     $action = $mcvEvent->getRouteMatch()->getParam('action');
     $routeName = $mcvEvent->getRouteMatch()->getMatchedRouteName();
     $controller = $mcvEvent->getRouteMatch()->getParam('controller');
     $route = array("routeName" => $routeName, "action" => $action, "controller" => $controller);
     //var_dump($route);
     $viewModel->setVariable('main_ruote', $route);
     $viewModel->setVariable('view_detail', $grid->getDataDetail());
 }
 public function createService(ServiceLocatorInterface $sm)
 {
     $config = $sm->get('config');
     if (!isset($config['zf2datatable'])) {
         throw new InvalidArgumentException('Config key "zf2datatable" is missing');
     }
     /* @var $application \Zend\Mvc\Application */
     $application = $sm->get('application');
     $grid = new Datagrid();
     $grid->setOptions($config['zf2datatable']);
     $grid->setMvcEvent($application->getMvcEvent());
     $grid->setServiceLocator($sm);
     $grid->setEventManager(new Zf2EventManager(array('Zf2datatable\\Datagrid', get_class($grid))));
     if ($sm->has('translator') === true) {
         $grid->setTranslator($sm->get('translator'));
     }
     if ($sm->has('zf2datatable_logger') === true) {
         $grid->setLogger($sm->get('zf2datatable_logger'));
     }
     $grid->init();
     return $grid;
 }
Exemplo n.º 3
0
 public function testCanAddCrudColumn()
 {
     $this->assertEquals(array(), $this->grid->getColumns());
     $this->grid->addCrudColumn();
     $this->assertCount(1, $this->grid->getColumns());
 }