Magento 1.7 – Fixing Grid Action with Ajax Not Working

ce-1.7.0.2magento-1.7magento-1.8

I added a tab to customer edit in admin magento, it's a grid. I used

$this->setUseAjax(true);

but when i filter, it's just loading and not show results. I have getGridUrl() in Custom.php:

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

And i have controller with grid action:

public function gridAction()
    {
        $this->loadLayout();
        $this->getResponse()->setBody(
            $this->getLayout()->createBlock('mymodule/adminhtml_customer_edit_tab_custom')->toHtml()
        );
    }

but still not filter

Best Answer

Yeah, i found solution following by marius's hint. My controller

Mymodule/controllers/Adminhtml/TestController.php

<?php

class Myextension_Mymodule_Adminhtml_TestController{

    public function gridAction()
    {
        $this->loadLayout();
        $this->getResponse()->setBody(
            $this->getLayout()->createBlock('mymodule/adminhtml_customer_edit_tab_custom')->toHtml()
        );
    }
}

My config.xml:

<admin>
 <routers>
    <adminhtml>
       <args>
        <modules>
          <myextension_mymodule before="Mage_Adminhtml">Myextension_Mymodule_Adminhtml</myextension_mymodule>
        </modules>
       </args>
    </adminhtml>
 </routers>
</admin>

Change

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

To

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