0

Just like the question keep the checkboxes of mass action checked for some items, by default, but I simply want all checkboxes checked by default, plus a default mass-action is selected on first landing.

E.g. a landing grid page: Screenshot

Should I just use JS to select them? Or there is a simpler way?

Community
  • 1
  • 1
Richard Fu
  • 616
  • 10
  • 27

2 Answers2

1

You may change default massaction block for your grid. Add in grid class:

protected $_massactionBlockName = 'adminhtml/widget_grid_massaction';

with your custom block (must be extend from Mage_Adminhtml_Block_Widget_Grid_Massaction)

And extend method getSelectedJson . To get all ids you may use $this->getParentBlock()->getCollection()->getAllIds().

  • I can select all checkboxes with your approach, but how about selecting the default action (Export in my case)? – Richard Fu Jan 29 '15 at 03:16
0

Extending what @SergeyGolubev suggested, do following:

Add this in Grid.php:

protected $_massactionBlockName = 'yourmodule/adminhtml_index_grid_massaction';

Then create a new file in .../Block/Adminhtml/Index/Grid/Massaction.php with following code:

class YourPackage_YourModule_Block_Adminhtml_Index_Grid_Massaction extends Mage_Adminhtml_Block_Widget_Grid_Massaction
{

    public function getSelectedJson()
    {
        $gridIds = $this->getParentBlock()->getCollection()->getAllIds();
        if(!empty($gridIds)) {
            return join(",", $gridIds);
        }
        return '';
    }

}
Richard Fu
  • 616
  • 10
  • 27