示例#1
0
 /**
  * Set $this->filter values after filter form submitted
  * @param  Form $form
  * @return void
  */
 public function filterSucceeded(Form $form)
 {
     if ($this->snippets_set) {
         return;
     }
     $values = $form->getValues();
     if ($this->getPresenter()->isAjax()) {
         if (isset($form['group_action']['submit']) && $form['group_action']['submit']->isSubmittedBy()) {
             return;
         }
     }
     /**
      * Per page
      */
     $this->saveSessionData('_grid_per_page', $values->per_page);
     $this->per_page = $values->per_page;
     /**
      * Inline edit
      */
     if (isset($form['inline_edit']) && isset($form['inline_edit']['submit']) && isset($form['inline_edit']['cancel'])) {
         $edit = $form['inline_edit'];
         if ($edit['submit']->isSubmittedBy() || $edit['cancel']->isSubmittedBy()) {
             $id = $form->getHttpData(Form::DATA_LINE, 'inline_edit[_id]');
             $primary_where_column = $form->getHttpData(Form::DATA_LINE, 'inline_edit[_primary_where_column]');
             if ($edit['submit']->isSubmittedBy()) {
                 $this->inlineEdit->onSubmit($id, $values->inline_edit);
                 $this->getPresenter()->payload->_datagrid_inline_edited = $id;
                 $this->getPresenter()->payload->_datagrid_name = $this->getName();
             } else {
                 $this->getPresenter()->payload->_datagrid_inline_edit_cancel = $id;
                 $this->getPresenter()->payload->_datagrid_name = $this->getName();
             }
             if ($edit['submit']->isSubmittedBy() && !empty($this->inlineEdit->onCustomRedraw)) {
                 $this->inlineEdit->onCustomRedraw();
             } else {
                 $this->redrawItem($id, $primary_where_column);
             }
             return;
         }
     }
     /**
      * Inline add
      */
     if (isset($form['inline_add']) && isset($form['inline_add']['submit']) && isset($form['inline_add']['cancel'])) {
         $add = $form['inline_add'];
         if ($add['submit']->isSubmittedBy() || $add['cancel']->isSubmittedBy()) {
             if ($add['submit']->isSubmittedBy()) {
                 $this->inlineAdd->onSubmit($values->inline_add);
                 if ($this->getPresenter()->isAjax()) {
                     $this->getPresenter()->payload->_datagrid_inline_added = TRUE;
                 }
             }
             return;
         }
     }
     /**
      * Filter itself
      */
     $values = $values['filter'];
     foreach ($values as $key => $value) {
         /**
          * Session stuff
          */
         $this->saveSessionData($key, $value);
         /**
          * Other stuff
          */
         $this->filter[$key] = $value;
     }
     if (!empty($values)) {
         $this->saveSessionData('_grid_has_filtered', 1);
     }
     if ($this->getPresenter()->isAjax()) {
         $this->getPresenter()->payload->_datagrid_sort = [];
         foreach ($this->columns as $key => $column) {
             if ($column->isSortable()) {
                 $this->getPresenter()->payload->_datagrid_sort[$key] = $this->link('sort!', ['sort' => $column->getSortNext()]);
             }
         }
     }
     $this->reload();
 }