cancel
Showing results for 
Search instead for 
Did you mean: 

Grid is showing blank page not loading grid data

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Grid is showing blank page not loading grid data

I have created a custom module one part is working fine that is adminform now i have create a grid to show all the data saved in database. But all i get is blank page.

Here is my grid.php file:

 

<?php

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

   public function __construct()
      {
    parent::__construct();
    $this->setId('reviewGrid');
    $this->setDefaultSort('id');
    $this->setDefaultDir('ASC');
    $this->setSaveParametersInSession(true);
}

protected function _prepareCollection()
{
    $collection = Mage::getModel('optfirst_reviewmycompany/review')->getCollection();
    print_r($collection);
    $this->setCollection($collection);
    return parent::_prepareCollection();
}

protected function _prepareColumns()
{
    $this->addColumn('id', array(
        'header' => Mage::helper('reviewmycompany')->__('ID'),
        'align' => 'right',
        'width' => '10px',
        'index' => 'id',
        ));

    $this->addColumn('name', array(
        'header' => Mage::helper('reviewmycompany')->__('Name'),
        'align' => 'left',
        'index' => 'name',
        'width' => '50px',
        ));


    $this->addColumn('content', array(
        'header' => Mage::helper('reviewmycompany')->__('Description'),
        'width' => '150px',
        'index' => 'content',
        ));
    return parent::_prepareColumns();
}

}

And here is my controller:

<?php

       class OptFirst_ReviewMyCompany_Adminhtml_ReviewController extends Mage_Adminhtml_Controller_action
        {

  public functio  indexAction() {
    $this->loadLayout();
            $this->renderLayout();

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

}

Can you please check what is wrong and why its not showing the grid container.

Thanks!

 

1 REPLY 1

Re: Grid is showing blank page not loading grid data

Hi @Shoaib_Fareedi,

 


Have you created the UI Component for the grid? You need that in order to render the grid, provide pagination, sorting and other features.

 

Here is a reference from the Magento 2 Developer Documentation:

http://devdocs.magento.com/guides/v2.0/ui-components/ui-listing-grid.html

 


Best regards.

Gabriel

Welcome to the Magento Forums. Remember to introduce yourself and read the Magento Forums Guidelines.