Magento – Ajax Not Working in Grid Edit Form (Backend)

formsgridgrid-serlization

I have included a product grid in edit form tab. ( same edit category does ), however when I search the ajax loader doesn't stop and I'm redirected to the main tab.

I can post part of code if needed but I would only if required ( many files involved )

UPDATE:

it looks like the problem is that the param $url passed to the function reload (grid.js) doesn't contains ?isAjax=true

Best Answer

There are quite some tutorials explaining how to add a custom admin grids. Unfortunately some of them are missing the fact that sorting and filtering functionality require additional controller action.

This action is specified by getGridUrl() method of your grid class. The pitfall is that this method is defined in Mage_Adminhtml_Block_Widget_Grid so if you forget to override it you may notice it until you try to sort or filter your grid. Mage_Adminhtml_Block_Widget_Grid::getGridUrl() returns $this->getCurrentUrl() which doesn't make much sense. So obvious move would be to override it with something like this:

public function getGridUrl()
{
    return $this->getUrl('*/*/grid', array('_current'=>true));
}

The simple controller action that will just render a layout will wrap things up:

public function gridAction()
{
    $this->loadLayout();
    $this->renderLayout();
}
Related Topic