Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
grid.phtml
Go to the documentation of this file.
1 <?php
7 // @codingStandardsIgnoreFile
8 
9 ?>
10 <?php
12 $numColumns = sizeof($block->getColumns());
13 ?>
14 <?php if ($block->getCollection()): ?>
15  <?php if ($block->canDisplayContainer()): ?>
16  <div id="<?= /* @escapeNotVerified */ $block->getId() ?>">
17  <?php else: ?>
18  <?= $block->getLayout()->getMessagesBlock()->getGroupedHtml() ?>
19  <?php endif; ?>
20  <?php if ($block->getStoreSwitcherVisibility() || $block->getDateFilterVisibility()): ?>
21  <div class="admin__data-grid-header admin__data-grid-toolbar">
22  <div class="admin__data-grid-header-row">
23  <?php if ($block->getDateFilterVisibility()): ?>
24  <div class="admin__filter-actions" data-role="filter-form" id="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_range') ?>">
25  <span class="field-row">
26  <label for="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from') ?>"
27  class="admin__control-support-text">
28  <span><?= /* @escapeNotVerified */ __('From') ?>:</span>
29  </label>
30  <input class="input-text no-changes required-entry admin__control-text"
31  type="text"
32  id="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from') ?>"
33  name="report_from"
34  value="<?= $block->escapeHtml($block->getFilter('report_from')) ?>">
35  <span id="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from_advice') ?>"></span>
36  </span>
37 
38  <span class="field-row">
39  <label for="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to') ?>"
40  class="admin__control-support-text">
41  <span><?= /* @escapeNotVerified */ __('To') ?>:</span>
42  </label>
43  <input class="input-text no-changes required-entry admin__control-text"
44  type="text"
45  id="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to') ?>"
46  name="report_to"
47  value="<?= $block->escapeHtml($block->getFilter('report_to')) ?>"/>
48  <span id="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to_advice') ?>"></span>
49  </span>
50 
51  <span class="field-row admin__control-filter">
52  <label for="<?= /* @escapeNotVerified */ $block->getSuffixId('report_period') ?>"
53  class="admin__control-support-text">
54  <span><?= /* @escapeNotVerified */ __('Show By') ?>:</span>
55  </label>
56  <select name="report_period" id="<?= /* @escapeNotVerified */ $block->getSuffixId('report_period') ?>" class="admin__control-select">
57  <?php foreach ($block->getPeriods() as $_value => $_label): ?>
58  <option value="<?= /* @escapeNotVerified */ $_value ?>" <?php if ($block->getFilter('report_period') == $_value): ?> selected<?php endif; ?>><?= /* @escapeNotVerified */ $_label ?></option>
59  <?php endforeach; ?>
60  </select>
61  <?= $block->getRefreshButtonHtml() ?>
62  </span>
63  <script>
64  require([
65  "jquery",
66  "mage/calendar"
67  ], function($){
68 
69  $("#<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_range') ?>").dateRange({
70  dateFormat:"<?= /* @escapeNotVerified */ $block->getDateFormat() ?>",
71  buttonText:"<?= /* @escapeNotVerified */ __('Select Date') ?>",
72  from:{
73  id:"<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from') ?>"
74  },
75  to:{
76  id:"<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to') ?>"
77  }
78  });
79  });
80  </script>
81  </div>
82  <?php endif; ?>
83  <?php if ($block->getChildBlock('grid.export')): ?>
84  <?= $block->getChildHtml('grid.export') ?>
85  <?php endif; ?>
86  </div>
87  </div>
88  <?php endif; ?>
89  <div class="admin__data-grid-wrap admin__data-grid-wrap-static">
90  <table class="data-grid" id="<?= /* @escapeNotVerified */ $block->getId() ?>_table">
91  <?= $block->getChildHtml('grid.columnSet') ?>
92  </table>
93  </div>
94  </div>
95  <?php if ($block->canDisplayContainer()): ?>
96  <script>
97  require([
98  "jquery",
99  "validation",
100  "mage/mage",
101  "mage/adminhtml/grid"
102  ], function(jQuery){
103 
104  //<![CDATA[
105  <?= /* @escapeNotVerified */ $block->getJsObjectName() ?> = new varienGrid('<?= /* @escapeNotVerified */ $block->getId() ?>', '<?= /* @escapeNotVerified */ $block->getGridUrl() ?>', '<?= /* @escapeNotVerified */ $block->getVarNamePage() ?>', '<?= /* @escapeNotVerified */ $block->getVarNameSort() ?>', '<?= /* @escapeNotVerified */ $block->getVarNameDir() ?>', '<?= /* @escapeNotVerified */ $block->getVarNameFilter() ?>');
106  <?= /* @escapeNotVerified */ $block->getJsObjectName() ?>.useAjax = '<?php if ($block->getUseAjax()): /* @escapeNotVerified */ echo $block->getUseAjax(); endif; ?>';
107  <?php if ($block->getDateFilterVisibility()): ?>
108  <?= /* @escapeNotVerified */ $block->getJsObjectName() ?>.doFilterCallback = validateFilterDate;
109  var period_date_from = $('<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from') ?>');
110  var period_date_to = $('<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to') ?>');
111  period_date_from.adviceContainer = $('<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from_advice') ?>');
112  period_date_to.adviceContainer = $('<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to_advice') ?>');
113 
114  var validateFilterDate = function() {
115  if (period_date_from && period_date_to) {
116  var valid = true;
117  jQuery(period_date_from).add(period_date_to).each(function() {
118  valid = Validation.validate(this) && valid;
119  });
120  return valid;
121  }
122  else {
123  return true;
124  }
125  }
126  <?php endif;?>
127  <?php if ($block->getStoreSwitcherVisibility()): ?>
128  /* Overwrite function from switcher.phtml widget*/
129  switchStore = function(obj) {
130  if (obj.options[obj.selectedIndex].getAttribute('website') == 'true') {
131  var selectionType = 'website';
132  } else if (obj.options[obj.selectedIndex].getAttribute('group') == 'true') {
133  var selectionType = 'group';
134  } else {
135  var selectionType = 'store';
136  }
137  var storeParam = obj.value ? selectionType + '/' + obj.value + '/' : '';
138  if (obj.switchParams) {
139  storeParam += obj.switchParams;
140  }
141  var formParam = new Array('<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from') ?>', '<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to') ?>', '<?= /* @escapeNotVerified */ $block->getSuffixId('report_period') ?>');
142  var paramURL = '';
143  var switchURL = '<?= /* @escapeNotVerified */ $block->getAbsoluteGridUrl(['_current' => false]) ?>'.replace(/(store|group|website)\/\d+\//, '');
144 
145  for (var i = 0; i < formParam.length; i++) {
146  if ($(formParam[i]).value && $(formParam[i]).name) {
147  paramURL += $(formParam[i]).name + '=' + escape($(formParam[i]).value) + '&';
148  }
149  }
150  setLocation(switchURL + storeParam + '?' + paramURL);
151  }
152  <?php endif; ?>
153  //]]>
154 
155  });
156  </script>
157  <?php endif; ?>
158 <?php endif; ?>
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition: block.php:9
__()
Definition: __.php:13
$block
Definition: block.php:8
endif
Definition: grid.phtml:31
$numColumns
Definition: grid.phtml:12
jQuery('.store-switcher .dropdown-menu li a').each(function()
Definition: switcher.phtml:203
$_value
Definition: tax.phtml:15
foreach( $block->getColumns() as $_column)() ?><? endforeach
Definition: grid.phtml:39