Search code examples
magentogridviewmagento-1.9

Magento 1.9 custom admin grid load inside itself


What my problem looks like

I have 2 grids in the same module (and i need to keep them in the same module). When i click on the top of the column the grid load itself inside itself.

Below is my code: Myname_Blink_Adminhtml_BlinkController

public function keywordsAction()
{
    $this->loadLayout();
    $this->_setActiveMenu('blink/keywords');
    $this->_addContent($this->getLayout()->createBlock('Myname_Blink_Block_Adminhtml_Keywords_Grid'));
    $this->renderLayout();
}

my block file : Myname_Blink_Block_Adminhtml_Keywords_Grid extends

class Myname_Blink_Block_Adminhtml_Keywords_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('keywords_grid');
        $this->setDefaultSort('keywords_id');
        $this->setDefaultDir('ASC');
        //$this->setSaveParametersInSession(true);
        $this->setUseAjax(true);
    }

As suggested to this post: Multiple grid in Magento admin

I removed the files: =>Myname_Blink_Block_Adminhtml_Keywords =>app\design\adminhtml\default\default\layout\myname\blink.xml


Solution

  • Maybe something goes wrong with AJAX call.
    Did you try this one: http://davemacaulay.com/fix-issue-with-magento-adminhtml-grid-ajax-call-containing-the-whole-page/

    public function keywordsAction()
    {
        if($this->getRequest()->isXmlHttpRequest()) {
            $this->getResponse()->setBody($this->getLayout()->createBlock('Myname_Blink_Block_Adminhtml_Keywords_Grid')->toHtml());
            return $this;
        }
    
        $this->loadLayout();
        $this->renderLayout();
    }
    

    Good luck!!!