1

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 need to go through all backend PHP for it?!?

1 Answer 1

4

You can have a selected mass action by default by defining it in your grid block like this:

   $this->getMassactionBlock()->addItem('mass_action_code_here', array(
        'label'    => Mage::helper('helper_name_here')->__('Label here'),
        'url'      => $this->getUrl('*/*/urlHere'),
        'selected' => true, //This is what you need
    ));

And you can select all the checkboxes by default like this.

Add a method called _prepareMassactionColumn in your grid block with this content.

protected function _prepareMassactionColumn()
{
    parent::_prepareMassactionColumn();
    $ids = Mage::getModel('your_model/alias_here')->getCollection()->getAllIds();
    $this->getColumn('massaction')->setValues($ids);
    return $this;
}
2
  • not working on magento 2.3 Commented Sep 13, 2019 at 7:50
  • @ManishMaheshwari Of course it doesn't. The question and answer are for magento 1.
    – Marius
    Commented Sep 13, 2019 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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