144 \
Magento\Backend\Helper\Data $backendHelper,
147 $this->_backendHelper = $backendHelper;
148 $this->_backendSession = $context->getBackendSession();
149 parent::__construct($context,
$data);
158 parent::_construct();
160 if (!$this->getRowClickCallback()) {
161 $this->setRowClickCallback(
'openGridRow');
165 $this->setId($this->
getData(
'id'));
168 if ($this->
hasData(
'default_sort')) {
172 if ($this->
hasData(
'default_dir')) {
176 if ($this->
hasData(
'save_parameters_in_session')) {
181 $this->
hasData(
'pager_visibility') ? (
bool)$this->
getData(
'pager_visibility') :
true 205 return $this->
getData(
'dataSource');
227 throw new \Magento\Framework\Exception\LocalizedException(
273 foreach ($this->
getColumns() as $columnId => $column) {
278 ) && !empty(
$data[$columnId]) || strlen(
280 ) > 0) && $column->getFilter()
282 $column->getFilter()->setValue(
$data[$columnId]);
298 $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
299 if ($column->getFilterConditionCallback()) {
302 $condition = $column->getFilter()->getCondition();
303 if ($field && isset($condition)) {
304 $this->
getCollection()->addFieldToFilter($field, $condition);
321 $columnIndex = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
322 $collection->setOrder($columnIndex, strtoupper($column->getDir()));
353 if ($filter ===
null) {
357 if (is_string($filter)) {
358 $data = $this->_backendHelper->prepareFilterString($filter);
361 }
elseif ($filter && is_array($filter)) {
363 }
elseif (0 !==
sizeof($this->_defaultFilter)) {
368 $dir = strtolower($dir) ==
'desc' ?
'desc' :
'asc';
369 $this->
getColumn($columnId)->setDir($dir);
395 $this->_eventManager->dispatch(
396 'backend_block_widget_grid_prepare_grid_before',
400 $this->
getChildBlock(
'grid.massaction')->prepareMassactionColumn();
404 if ($this->hasColumnRenderers()) {
405 foreach ($this->getColumnRenderers() as $renderer => $rendererClass) {
406 $this->
getColumnSet()->setRendererType($renderer, $rendererClass);
409 if ($this->hasColumnFilters()) {
410 foreach ($this->getColumnFilters() as $filter => $filterClass) {
411 $this->
getColumnSet()->setFilterType($filter, $filterClass);
414 $this->
getColumnSet()->setSortable($this->getSortable());
436 'reset_filter_button',
441 'label' =>
__(
'Reset Filter'),
443 'class' =>
'action-reset action-tertiary' 445 )->setDataAttribute([
'action' =>
'grid-filter-reset'])
453 'label' =>
__(
'Search'),
455 'class' =>
'action-secondary',
457 )->setDataAttribute([
'action' =>
'grid-filter-apply'])
469 return parent::_beforeToHtml();
530 $this->_varNameLimit =
$name;
542 $this->_varNamePage =
$name;
554 $this->_varNameSort =
$name;
566 $this->_varNameDir =
$name;
578 $this->_varNameFilter =
$name;
590 $this->_pagerVisibility = $visible;
613 $this->_messageBlockVisibility = $visible;
635 $this->_defaultLimit = $limit;
647 $this->_defaultPage =
$page;
659 $this->_defaultSort = $sort;
671 $this->_defaultDir = $dir;
683 $this->_defaultFilter = $filter;
729 public function getParam($paramName, $default =
null)
731 $sessionParamName = $this->
getId() . $paramName;
733 $param = $this->
getRequest()->getParam($paramName);
734 if ($this->_saveParametersInSession) {
735 $this->_backendSession->setData($sessionParamName, $param);
738 }
elseif ($this->_saveParametersInSession && ($param = $this->_backendSession->getData($sessionParamName))) {
753 $this->_saveParametersInSession = $flag;
764 return preg_replace(
"~[^a-z0-9_]*~i",
'', $this->
getId()) .
'JsObject';
775 $this->_countTotals =
$count;
getData($key='', $index=null)
elseif(isset( $params[ 'redirect_parent']))
call_user_func($callable, $param)
setData($key, $value=null)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
getChildHtml($alias='', $useCache=true)
if(!isset($_GET['name'])) $name