20 class Extended extends \Magento\Backend\Block\Widget\Grid implements \Magento\Backend\Block\Widget\Grid\ExportInterface
165 protected $_template =
'Magento_Backend::widget/grid/extended.phtml';
184 parent::_construct();
185 $this->_emptyText =
__(
'We couldn\'t find any records.');
201 'label' =>
__(
'Export'),
208 'reset_filter_button',
211 'label' =>
__(
'Reset Filter'),
213 'class' =>
'action-reset action-tertiary' 217 'action' =>
'grid-filter-reset' 225 'label' =>
__(
'Search'),
227 'class' =>
'task action-secondary',
231 'action' =>
'grid-filter-apply' 235 return parent::_prepareLayout();
251 return parent::getColumnSet();
273 $this->_exportTypes[] = new \Magento\Framework\DataObject(
289 if (is_array($column)) {
298 $this->
getColumnSet()->getChildBlock($columnId)->setGrid($this);
300 throw new \Exception(
__(
'Please correct the column format and try again.'));
303 $this->_lastColumnId = $columnId;
317 if ($this->_lastColumnId == $columnId) {
319 $this->_lastColumnId = array_pop($names);
349 $this->_columnsOrder[$columnId] = $after;
379 $this->_lastColumnId = array_pop(
$columns);
436 $columnId =
'massaction';
443 'type' =>
'massaction',
446 'header_css_class' =>
'col-select',
447 'column_css_class' =>
'col-select',
451 if ($this->getNoFilterMassactionColumn()) {
452 $massactionColumn->setData(
'filter',
false);
455 $massactionColumn->setSelected($this->
getMassactionBlock()->getSelected())->setGrid($this)->setId($columnId);
478 parent::_prepareCollection();
480 if (!$this->_isExport) {
508 parent::_prepareGrid();
540 $this->_massactionIdField = $idField;
562 $this->_massactionIdFilter = $idFilter;
584 $this->_massactionBlockName = $blockName;
630 if (!
$item->getIsEmpty()) {
654 $this->_emptyCellLabel =
$label;
666 $res = parent::getRowUrl(
$item);
667 return $res ? $res :
'#';
678 return $item->getChildren();
688 foreach ($this->_groupedColumn as $column) {
702 return $this->_countSubTotals && count($this->_subtotals) > 0 && count($this->
getMultipleRows(
$item)) > 0;
730 if (is_object($column)) {
733 return in_array($column, $this->_groupedColumn);
735 $this->_groupedColumn[] = $column;
748 return $item->getIsEmpty() && in_array($column[
'index'], $this->_groupedColumn);
769 foreach ($this->_subtotals as $subtotalItem) {
770 foreach ($this->_groupedColumn as $groupedColumn) {
771 if ($subtotalItem->getData($groupedColumn) ==
$item->getData($groupedColumn)) {
772 return $subtotalItem;
797 $this->_headersVisibility = $visible;
819 $this->_filterVisibility = $visible;
841 $this->_emptyText =
$text;
885 $this->_isCollapsed = $isCollapsed;
908 return $this->_directory->readFile(
'export/' . $fileData[
'value']);
920 if (!$column->getIsSystem()) {
921 $row[] = $column->getExportHeader();
937 if (!$column->getIsSystem()) {
938 $row[] = $column->hasTotalsLabel() ? $column->getTotalsLabel() : $column->getRowFieldExport(
$totals);
960 while ($break !==
true) {
969 if ($lPage ==
$page) {
975 call_user_func_array([$this, $callback], array_merge([
$item], $args));
993 if (!$column->getIsSystem()) {
994 $row[] = $column->getRowFieldExport(
$item);
997 $stream->writeCsv(
$row);
1009 $this->_isExport =
true;
1012 $name = md5(microtime());
1013 $file = $this->_path .
'/' .
$name .
'.csv';
1015 $this->_directory->create($this->_path);
1016 $stream = $this->_directory->openFile($file,
'w+');
1030 'type' =>
'filename',
1044 $this->_isExport =
true;
1053 if (!$column->getIsSystem()) {
1054 $data[] =
'"' . $column->getExportHeader() .
'"';
1057 $csv .= implode(
',',
$data) .
"\n";
1062 if (!$column->getIsSystem()) {
1063 $data[] =
'"' . str_replace(
1066 $column->getRowFieldExport(
$item)
1070 $csv .= implode(
',',
$data) .
"\n";
1076 if (!$column->getIsSystem()) {
1077 $data[] =
'"' . str_replace(
1080 $column->getRowFieldExport($this->getTotals())
1084 $csv .= implode(
',',
$data) .
"\n";
1097 $this->_isExport =
true;
1105 if (!$column->getIsSystem()) {
1106 $indexes[] = $column->getIndex();
1109 $xml =
'<?xml version="1.0" encoding="UTF-8"?>';
1112 $xml .=
$item->toXml($indexes);
1115 $xml .= $this->
getTotals()->toXml($indexes);
1131 if (!$column->getIsSystem()) {
1132 $row[] = $column->getRowFieldExport(
$data);
1148 $this->_isExport =
true;
1151 $convert = new \Magento\Framework\Convert\Excel(
1153 [$this,
'getRowRecord']
1156 $name = md5(microtime());
1157 $file = $this->_path .
'/' .
$name .
'.xml';
1159 $this->_directory->create($this->_path);
1160 $stream = $this->_directory->openFile($file,
'w+');
1168 $convert->write($stream, $sheetName);
1173 'type' =>
'filename',
1186 $this->_isExport =
true;
1195 if (!$column->getIsSystem()) {
1196 $headers[] = $column->getHeader();
1204 if (!$column->getIsSystem()) {
1214 if (!$column->getIsSystem()) {
1221 $convert = new \Magento\Framework\Convert\Excel(
new \ArrayIterator(
$data));
1222 return $convert->convert(
'single_sheet');
1264 $this->_countSubTotals = $flag;
1287 $this->_subtotals =
$items;
getUrl($route='', $params=[])
setData($key, $value=null)
getChildHtml($alias='', $useCache=true)
if(!isset($_GET['name'])) $name