I have created split button i.e. button with options as below.
Created block file
namespace Yournamespace\Modulename\Block\Adminhtml\Product; class CustomActionList extends \Magento\Backend\Block\Widget\Container { /** * @param \Magento\Backend\Block\Widget\Context $context * @param array $data */ public function __construct( \Magento\Backend\Block\Widget\Context $context, array $data = [] ) { parent::__construct($context, $data); } protected function _prepareLayout() { $addButtonProps = [ 'id' => 'custom_action_list', 'label' => __('Custom Action List'), 'class' => 'add', 'button_class' => '', 'class_name' => 'Magento\Backend\Block\Widget\Button\SplitButton', 'options' => $this->_getCustomActionListOptions(), ]; $this->buttonList->add('add_new', $addButtonProps); return parent::_prepareLayout(); } /** * Retrieve options for 'CustomActionList' split button * * @return array */ protected function _getCustomActionListOptions() { /*list of button which you want to add*/ $splitButtonOptions=[ 'action_1'=>['label'=>__('Action 1'),'onclick'=>'setLocation("ACTION CONTROLLER")'], 'action_2'=>['label'=>__('Action 2'),'onclick'=>'setLocation("ACTION CONTROLLER")'], 'action_3'=>['label'=>__('Action 3'),'onclick'=>'setLocation("ACTION CONTROLLER")'] ]; /* in above list you can also pass others attribute of buttons*/ return $splitButtonOptions; } }
Created block file
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="content"> <!-- here we call our split button block --> <block class="Yournamespace\Modulename\Block\Adminhtml\Product\CustomActionList" name="admin.product.customsplitbutton"/> </referenceContainer> </body> </page>
I am using this button in grid, beside Add New button .
But when I select items from grid and I click on button action, I am not getting selected row's data.