ylliX - Online Advertising Network

Quick tip: Ajax filter is not working in Magento grid?

It is a common issue, you added:

$this->setUseAjax(true);

but filtering just shows ajax spinner and not loading content? Check your grid class ([COMPANY]_[MODULE]_Block_Adminhtml_[CONTROLLER]_Grid extending from Mage_Adminhtml_Block_Widget_Grid) and if you don’t have getGridUrl(), it is the reason. Just add as shown:

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

keep in mind to match ‘*/[CONTROLLER]/grid’ to your controller, it should be gridAction() method in controllers/Adminhtml/[CONTROLLER]Controller.php with such content:

public function gridAction() {
    $this->loadLayout();
    $this->getResponse()->setBody(
	    $this->getLayout()->createBlock('[COMPANY]_[MODULE]/adminhtml_[CONTROLLER]')->toHtml()
    );
}

Leave a Reply