/**
  * Get the default filter conditions defined for the columns
  *
  * @return array
  */
 public function getFiltersDefault()
 {
     $filters = array();
     // @todo skip this, if $grid->isUserFilterEnabled() ?
     if ($this->getRequest() instanceof ConsoleRequest || $this->getRequest() instanceof HttpRequest && !$this->getRequest()->isPost()) {
         foreach ($this->getColumns() as $column) {
             /* @var $column \ZfcDatagrid\Column\AbstractColumn */
             if ($column->hasFilterDefaultValue() === true) {
                 $filter = new Filter();
                 $filter->setFromColumn($column, $column->getFilterDefaultValue());
                 $filters[] = $filter;
                 $column->setFilterActive($filter->getDisplayColumnValue());
             }
         }
     }
     return $filters;
 }
 public function testFilter()
 {
     $source = clone $this->source;
     /*
      * LIKE
      */
     $filter = new Filter();
     $filter->setFromColumn($this->colVolumne, '~7');
     $source->addFilter($filter);
     $source->execute();
     // $this->assertEquals(2, $source->getPaginatorAdapter()
     // ->count());
 }
Ejemplo n.º 3
0
 /**
  * Load the data detail
  */
 public function loadDataCrud($identity, $render = 'getFormRenderer', $action = 'editCrud')
 {
     if ($this->hasDataSource() === false) {
         throw new \Exception('No datasource defined! Please call "setDataSource()" first"');
     }
     // var_dump($this->getDataSource ()->executeDetail ( $filter ));
     $renderer = $this->{$render}();
     /**
      * Step 1.1) Filtering Column
      */
     foreach ($renderer->getFilters() as $filter) {
         $this->getDataSource()->addFilter($filter);
     }
     /**
      * Step 1.2) Filtering from Crud
      */
     $filterCrudColumn = $this->getConditionCrudColumn()[$action];
     if (is_array($filterCrudColumn)) {
         $oFilter = new Filter();
         $oFilter->setFromColumn($filterCrudColumn['field'], $filterCrudColumn['filter_operator'] . $filterCrudColumn['filter_crud']);
         $this->getDataSource()->addFilter($oFilter);
     }
     $entityObject = $this->getDataSource()->findByIdentity($identity);
     $entityObject = is_object($entityObject) || is_array($entityObject) ? $entityObject : $this->getDataSource()->getDefaultBindObject();
     $this->setCrudDetail($entityObject);
     return $this;
 }
Ejemplo n.º 4
0
 public function testBetween()
 {
     $filter = new Filter();
     $filter->setFromColumn($this->column, '2<>3');
     $this->assertEquals(Filter::BETWEEN, $filter->getOperator());
     $this->assertEquals('2 <> 3', $filter->getDisplayColumnValue());
     $this->assertEquals(array('2', '3'), $filter->getValues());
     $filter = new Filter();
     $filter->setFromColumn($this->column, '2<>3 <>4');
     $this->assertEquals(Filter::BETWEEN, $filter->getOperator());
     $this->assertEquals('2 <> 4', $filter->getDisplayColumnValue());
     $this->assertEquals(array('2', '4'), $filter->getValues());
 }