Пример #1
0
 /**
  * Return data array
  * 
  * @return array
  */
 public function getData($dataSource)
 {
     $limit = $this->_grid->getLimit();
     //$extraLimit = $this->_grid->getExtraLimit();
     $extraLimit = 100;
     $page = $this->_grid->getPage();
     $extraPage = (int) ceil($limit * $page / $extraLimit);
     $paginator = $this->_getPaginator($dataSource, $extraLimit, $extraPage);
     $items = [];
     $position = $limit * ($page - 1) - $extraLimit * ($extraPage - 1);
     if ($paginator->total_items > 0) {
         for ($i = $position; $i < $position + $limit; ++$i) {
             if (!isset($paginator->items[$i])) {
                 break;
             }
             $items[] = $paginator->items[$i];
         }
     }
     $data = ['data' => $items, 'page' => $page, 'limit' => $limit, 'mess_now' => count($items)];
     if ($this->_grid->isCountQuery()) {
         $data['pages'] = (int) ceil($paginator->total_items / $limit);
         $data['lines'] = $paginator->total_items;
     }
     return $data;
 }
Пример #2
0
 /**
  * Return column sort params
  *
  * @param bool $withFilterParams
  * @return array
  */
 public function getSortParams($withFilterParams = true)
 {
     $params = [];
     $sortParamName = $this->_grid->getSortParamName();
     $sortDirectionParamName = $this->_grid->getSortDirectionParamName();
     $params[$sortParamName] = $this->_key;
     $params[$sortDirectionParamName] = $this->toogleSortDirection();
     $limit = $this->_grid->getLimit();
     if ($limit != $this->_grid->getDefaultParam('limit')) {
         $limitParamName = $this->_grid->getLimitParamName();
         $params[$limitParamName] = $limit;
     }
     if ($withFilterParams) {
         $params += $this->_grid->getFilterParams();
     }
     return $params;
 }