public function renderCellTemplate($columnName) { $options = []; if ($columnName == 'currencyCode' && isset($this->_columns[$columnName])) { $optionsCurency = $this->_objectManager->get('Magento\\Directory\\Model\\Currency')->getConfigAllowCurrencies(); foreach ($optionsCurency as $code => $currency) { $options[] = ['value' => $currency, 'label' => $currency]; } } else { if ($columnName == 'store' && isset($this->_columns[$columnName])) { $options = $this->_systemStore->getStoreValuesForForm(false, false); } else { if ($columnName == 'countryCode' && isset($this->_columns[$columnName])) { $optionsCurency = $this->_geoipHelper->getCountryList(); foreach ($optionsCurency as $code => $country) { $options[] = ['value' => $code, 'label' => $country]; } /*$options = $this->_objectManager->get('Magento\Directory\Model\Config\Source\Country')->toOptionArray(); array_shift($options);*/ } } } if (count($options) > 0) { $element = $this->_elementFactory->create('select'); $element->setForm($this->getForm())->setName($this->_getCellInputElementName($columnName))->setHtmlId($this->_getCellInputElementId('<%- _id %>', $columnName))->setValues($options); return str_replace("\n", '', $element->getElementHtml()); } return parent::renderCellTemplate($columnName); }
/** * {@inheritdoc} */ protected function _construct() { $this->setTemplate('config/form/field/array.phtml'); $this->_addAfter = false; $this->_addButtonLabel = __('Add'); parent::_construct(); }
protected function _construct() { $this->addColumn('magento', ['label' => __('Magento')]); $this->addColumn('mailchimp', ['label' => __('MailChimp')]); $this->_addAfter = false; $this->_addButtonLabel = __('Add'); parent::_construct(); }
protected function _construct() { $this->addColumn('magento', ['label' => __('Magento Template'), 'renderer' => $this->getMagentoTemplateRenderer()]); $this->addColumn('mandrill', ['label' => __('Mandrill Template'), 'renderer' => $this->getMandrillTemplateRenderer()]); $this->_addAfter = false; $this->_addButtonLabel = __('Add'); parent::_construct(); }
protected function _construct() { $this->addColumn('magento', ['label' => __('Magento')]); $this->addColumn('sendpulse', ['label' => __('SendPulse')]); $this->_addAfter = false; $this->_addButtonLabel = __('Add'); parent::_construct(); }
/** * Initialise columns for 'Store Locations' * * @return void */ protected function _construct() { $this->addColumn('title', ['label' => __('Title'), 'class' => 'validate-no-empty validate-alphanum-with-spaces']); $this->addColumn('street', ['label' => __('Street Address'), 'class' => 'validate-no-empty validate-alphanum-with-spaces']); $this->addColumn('phone', ['label' => __('Phone Number'), 'class' => 'validate-no-empty validate-no-empty validate-phoneStrict']); $this->addColumn('message', ['label' => __('Message'), 'class' => 'validate-no-empty']); $this->_addAfter = false; parent::_construct(); }
/** * @param \Magento\Backend\Block\Context $context * @param \Magento\Backend\Model\Auth\Session $authSession * @param \Magento\Framework\View\Helper\Js $jsHelper * @param array $data */ public function __construct(\Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Auth\Session $authSession, \Magento\Framework\View\Helper\Js $jsHelper, \MercadoPago\MercadoEnvios\Helper\Data $helper, \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection $attributeCollection, array $data = []) { $this->addColumn('mercadoenvios', array('label' => __('MercadoEnvíos'), 'style' => 'width:120px')); $this->addColumn('magentoproduct', array('label' => __('Product Attribute'), 'style' => 'width:120px')); $this->addColumn('unit', array('label' => __('Attribute Unit'), 'style' => 'width:120px')); $this->setTemplate('array_dropdown.phtml'); $this->helper = $helper; $this->attributeCollection = $attributeCollection; parent::__construct($context); }
/** * Render array cell for prototypeJS template * * @param string $columnName * @return string */ public function renderCellTemplate($columnName) { if ($columnName == 'value' && isset($this->_columns[$columnName])) { /** @var $label \Magento\Framework\View\Design\Theme\Label */ $label = $this->_labelFactory->create(); $options = $label->getLabelsCollection(__('-- No Theme --')); $element = $this->_elementFactory->create('select'); $element->setForm($this->getForm())->setName($this->_getCellInputElementName($columnName))->setHtmlId($this->_getCellInputElementId('<%- _id %>', $columnName))->setValues($options); return str_replace("\n", '', $element->getElementHtml()); } return parent::renderCellTemplate($columnName); }
/** * Render array cell for JS template * * @param string $columnName The column name * * @return string */ public function renderCellTemplate($columnName) { if ($columnName == 'term_id' && isset($this->_columns[$columnName])) { $element = $this->elementFactory->create('hidden'); $element->setId("term_id")->setName("term_id"); $element->setForm($this->getForm())->setName($this->_getCellInputElementName($columnName))->setHtmlId($this->_getCellInputElementId('<%- _id %>', $columnName)); return $element->getElementHtml(); } if ($columnName == 'values' && isset($this->_columns[$columnName])) { $element = $this->elementFactory->create('textarea'); $element->setCols($this->textAreaColsNumber)->setForm($this->getForm())->setName($this->_getCellInputElementName($columnName))->setHtmlId($this->_getCellInputElementId('<%- _id %>', $columnName)); return str_replace("\n", '', $element->getElementHtml()); } return parent::renderCellTemplate($columnName); }
protected function _construct() { $data = $this->getTableData(); foreach (array_keys($data) as $columnId) { $columnData = $data[$columnId]; $column = ['label' => __($columnData['label'])]; if (isset($columnData['values'])) { $column['renderer'] = $this->getRenderer($columnId, $columnData); } if (isset($columnData['class'])) { $column['class'] = $columnData['class']; } if (isset($columnData['style'])) { $column['style'] = $columnData['style']; } $this->addColumn($columnId, $column); } $this->_addAfter = false; parent::_construct(); }
public function _toHtml() { return '<input type="hidden" id="' . $this->getElement()->getHtmlId() . '"/>' . parent::_toHtml(); }
public function _toHtml() { $script = "<script type=\"text/javascript\">\n require([\n 'prototype',\n 'domReady!'\n ], function () {\n \$\$('.admin__control-table tr td:first-child select').each(function(item) {\n doUpdateWithValues(item);\n });\n\n \$\$('.admin__control-table tr td:first-child select').each(function(item) {\n Event.observe(item,'change', function(){\n doUpdate(item);\n });\n });\n\n \$\$('.admin__control-table button.action-add').each(function(item) {\n Event.observe(item,'click', function(){\n \$\$('.admin__control-table tr td:first-child select').each(function(item) {\n Event.observe(item,'change', function(){\n doUpdate(item);\n });\n });\n \$\$('.admin__control-table tr td select').each(function(item) {\n Event.observe(item,'change', function(){\n if(item.readAttribute('title') == 'conditions'){\n doUpdateForCondition(item);\n }\n });\n });\n });\n });\n\n function doUpdate(item){\n var url = '" . $this->getUrl('dotdigitalgroup_email/rules/ajax') . "';\n var cond = item.up(1).down().next();\n var condName = cond.down().readAttribute('name');\n var value = item.up(1).down().next(1);\n var valueName = value.down().readAttribute('name');\n var attribute = item.value;\n new Ajax.Request(url, {\n method: 'post',\n parameters: {\n attribute: attribute,\n condition: condName,\n value: valueName\n },\n onSuccess: function(transport){\n var json = transport.responseJSON;\n cond.update(json.condition);\n value.update(json.cvalue);\n\n \$\$('.admin__control-table tr td select').each(function(item) {\n Event.observe(item,'change', function(){\n if(item.readAttribute('title') == 'conditions'){\n doUpdateForCondition(item);\n }\n });\n });\n }\n });\n }\n\n function doUpdateWithValues(item){\n var url = '" . $this->getUrl('dotdigitalgroup_email/rules/selected') . "';\n var arrayKey = item.up(1).readAttribute('id');\n var cond = item.up(1).down().next();\n var condName = cond.down().readAttribute('name');\n var value = item.up(1).down().next(1);\n var valueName = value.down().readAttribute('name');\n var attribute = item.value;\n var ruleId = \$('rule_id').value;\n new Ajax.Request(url, {\n method: 'post',\n parameters: {\n attribute: attribute,\n condition: condName,\n value: valueName,\n arraykey: arrayKey,\n ruleid: ruleId\n },\n onSuccess: function(transport){\n var json = transport.responseJSON;\n cond.update(json.condition);\n value.update(json.cvalue);\n\n \$\$('.admin__control-table tr td select').each(function(item) {\n Event.observe(item,'change', function(){\n if(item.readAttribute('title') == 'conditions'){\n doUpdateForCondition(item);\n }\n });\n });\n }\n });\n }\n\n function doUpdateForCondition(item){\n var url = '" . $this->getUrl('dotdigitalgroup_email/rules/value') . "';\n var attribute = item.up(1).down();\n var attributeValue = attribute.down().value;\n var value = item.up().next();\n var valueName = value.down().readAttribute('name');\n var condValue = item.value;\n new Ajax.Request(url, {\n method: 'post',\n parameters: {\n attributeValue: attributeValue,\n value: valueName,\n condValue: condValue\n },\n onSuccess: function(transport){\n var json = transport.responseJSON;\n value.update(json.cvalue);\n }\n });\n }\n });\n </script>"; return '<input type="hidden" id="' . $this->getElement()->getHtmlId() . '"/>' . parent::_toHtml() . $script; }