예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function getPaginationParameters(DatagridInterface $datagrid, $page)
 {
     $values = $datagrid->getValues();
     $values['_sort_by'] = $values['_sort_by']->getName();
     $values['_page'] = $page;
     return array('filter' => $values);
 }
예제 #2
0
    /**
     * Returns the parameters used in the columns header
     *
     * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
     * @param \Sonata\AdminBundle\Datagrid\DatagridInterface $datagrid
     * @return string
     */
    public function getSortParameters(FieldDescriptionInterface $fieldDescription, DatagridInterface $datagrid)
    {
        $values = $datagrid->getValues();

        if ($fieldDescription->getOption('sortable') == $values['_sort_by']) {
            if ($values['_sort_order'] == 'ASC') {
                $values['_sort_order'] = 'DESC';
            } else {
                $values['_sort_order'] = 'ASC';
            }
        } else {
            $values['_sort_order']  = 'ASC';
            $values['_sort_by']     = $fieldDescription->getOption('sortable');
        }

        return $values;
    }