2

I've built an admin grid following this tutorial: http://inchoo.net/magento/how-to-create-a-custom-grid-from-scratch/

My issue is that when I use any of the grid controls (pagination or filters), and it uses ajax to get the updated list, then adds a second instance of the text "Some Sample Header Text"?

The text itself comes from the class Ebuynow_Ebnreports_Block_Adminhtml_Shipments_Report

public function __construct()
{
    $this->_blockGroup = 'ebuynow_ebnreports';
    $this->_controller = 'adminhtml_shipments_report';
    $this->_headerText = Mage::helper('ebuynow_ebnreports')
        ->__('Some Sample Header Text');
    parent::__construct();
    $this->removeButton('add');
}

In controllers/Adminhtml/Shipments/ReportController, I have these methods responsible for building the initial grid and replying with contents for the ajax option, respectively.

public function indexAction()
{
    $this->_title($this->__('Incoming Shipments'))
        ->_title($this->__('sub title?'));
    $this->loadLayout();
    $this->_setActiveMenu('sales/sales');
    $block = $this->getLayout()
        ->createBlock('ebuynow_ebnreports/adminhtml_shipments_report');
    $this->_addContent($block);
    $this->renderLayout();
}
public function gridAction()
{
    $this->loadLayout();
    $block = $this->getLayout()
        ->createBlock('ebuynow_ebnreports/adminhtml_shipments_report');
    $this->getResponse()->setBody($block->toHtml());
}

To me, this looks correct, but I am hoping that someone with some magento experience can point out something that could cause this issue.

5

The problem was caused by the string used in one of the createBlock() calls.

To wit, Magento grids consist of a Grid Container class, and a Grid class, which both live in the Block directory of a magento module.

My createBlock() strings ebuynow_ebnreports/adminhtml_shipments_report were specifying the grid container, when one of them should have been specifying the Grid widget class. Changing the call to ebuynow_ebnreports/adminhtml_shipments_report_grid in gridAction() fixed the issue.

This was a vexing issue because even when I was calling the container class, the grid itself appeared to work. It would have been better if it just failed until I got the block string correct, so I would have known I was not doing it correctly.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.