In Magento 2.2.5, I am creating admin grid by following this tutorial(Using layout Block method. Not UI Component).
在Magento 2.2.5中,我按照本教程创建管理网格(使用布局块方法。不是UI组件)。
In that I have a add button. I can't remove it. I need to remove it and add a new button with custom url. How to achieve this.
在那我有一个添加按钮。我无法删除它。我需要将其删除并添加一个带有自定义网址的新按钮。如何实现这一目标。
Screenshot:
2 个解决方案
#1
5
You can use update
您可以使用更新
parent::_construct();
$this->buttonList->update('save', 'onclick', 'setLocation(\'' . $this->getUrl('*/*/<youraction>') . '\')');
#2
0
Try using this code
尝试使用此代码
parent::_construct();
$this->removeButton('add');
$this->buttonList->add(
'<your name>',
[
'label' => __('<your label>'),
'class' => 'save',
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/<youraction>') . '\')',
'style' => ' background-color: #ba4000; border-color: #b84002; box-shadow: 0 0 0 1px #007bdb;color: #fff;text-decoration: none;'
]
);
Hope that will help you.
希望能帮到你。
#1
5
You can use update
您可以使用更新
parent::_construct();
$this->buttonList->update('save', 'onclick', 'setLocation(\'' . $this->getUrl('*/*/<youraction>') . '\')');
#2
0
Try using this code
尝试使用此代码
parent::_construct();
$this->removeButton('add');
$this->buttonList->add(
'<your name>',
[
'label' => __('<your label>'),
'class' => 'save',
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/<youraction>') . '\')',
'style' => ' background-color: #ba4000; border-color: #b84002; box-shadow: 0 0 0 1px #007bdb;color: #fff;text-decoration: none;'
]
);
Hope that will help you.
希望能帮到你。