In Magento 2.2.5, I am creating admin grid by following this tutorial(Using layout Block method. Not UI Component).

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.



  • Can you share your code? – Chirag Patel Oct 22 '18 at 9:21

You can use update

$this->buttonList->update('save', 'onclick', 'setLocation(\'' . $this->getUrl('*/*/<youraction>') . '\')');

Try using this code


            '<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.

  • Yes, It is working. I have tried this but before parent::_construct(); i added this remove button code. So It is not worked. – Saravanan DS Oct 16 '18 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.