Search code examples
phpmagentobackend

Mass action doesn't work for Magento backend grid serializer


I've created a grid inside the tab using grid serializer using this tutorial. Then I've added a massaction to this grid using this tutorial.

Mass action block has appeared, but when I choose entities, choose massaction and click Submit, following error has been thrown to browser's console:

"ReferenceError: {gridId}_massactionJsObject is not defined"

Have anybody ever tried to add a mass action to the grid inside the tab? How to solve this error?


Solution

  • Instead of removing var in the abstract class just set the object to the window.

    in app/design/adminhtml/default/default/template/widget/grid.phtml calls out to getAdditionalJavascript()

    In your grid file add this function.

    protected function getAdditionalJavascript() {
        return 'window.{gridId}_massactionJsObject = {gridId}_massactionJsObject;';
    }