0

I am getting the error in my custom admin module -

 Fatal error: Call to a member function setSaveParametersInSession() on a non-object in /var/www/html/B2BMarkets/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php on line 66

Siteadmin_Approval is my module name. Here is controller -

class Siteadmin_Approval_Adminhtml_ApprovalController extends Mage_Adminhtml_Controller_action
{

    protected function _initAction() {
        $this->loadLayout()
            ->_setActiveMenu('siteadmin/approval');

        return $this;
        }


    public function indexAction() { 

        $this->_initAction()
            ->renderLayout();
    }

        public function viewAction() {

                $this->_initAction();
                $this->_addContent($this->getLayout()
                            ->createBlock('approval/adminhtml_approval_view'))
                    ->_addLeft($this->getLayout()
                            ->createBlock('approval/adminhtml_approval_view_tabs'));
                $this->renderLayout();
        }
}

and Block -

app/code/local/Siteadmin/Approval/Block/Adminhtml/Approval/View.php


class Siteadmin_Approval_Block_Adminhtml_Approval_View extends
                    Mage_Adminhtml_Block_Widget_Grid_Container {
  public function __construct()
  {
        parent::__construct();
        $this->_controller = 'adminhtml_approval_view';
        $this->_blockGroup = 'approval';
        $this->_headerText = Mage::helper('approval')->__('Company Users');


        $this->_removeButton('add');
        $data = array(
        'label' =>  'Back',
        'onclick'   => 'setLocation(\'' . $this->getUrl('*/*') . '\')',
        'class'     =>  'back'
            );
        $this->addButton ('my_back', $data, 0, 100,  'header'); 

        $this->_removeButton('back');
  }

}

and app/code/local/Siteadmin/Approval/Block/Adminhtml/Approval/View/View.php

class Siteadmin_Approval_Block_Adminhtml_Approval_View extends
                    Mage_Adminhtml_Block_Widget_Grid {
  public function __construct()
  {
        parent::__construct();
        $this->setId('company_user_id');
        $this->setUseAjax(FALSE);

        $this->setDefaultSort('id');
        $this->setDefaultDir(Varien_Data_Collection::SORT_ORDER_ASC);
        $this->setSaveParametersInSession(TRUE);
  }

  protected function _prepareCollection()
  {
     $comp_id = Mage::getSingleton('admin/session')->getCompanyId();

     $catalog_id = $this->getRequest()->getParam("id");

     try {
      $collection = Mage::getModel('newuser/companyuser')->getCollection()
                     ->addFieldToFilter("company_details_id", array("eq"=>$this->getRequest()->getParam("id")));


      $this->setCollection($collection);

     } catch(Exception $e)
      {
            Mage::getSingleton('adminhtml/session')
                                 ->addError($e->getMessage());
               Mage::getSingleton('adminhtml/session')
                ->settestData($this->getRequest()
                                   ->getPost()
               );
               $this->_redirect('*/*/index',
                           array('id' => $this->getRequest()
                                               ->getParam('id')));
               return;
      }

      return parent::_prepareCollection();
  }

  protected function _prepareColumns()
  {
      $this->addColumn('first_name', array(
          'header'    => Mage::helper('approval')->__('First Name'),
          'align'     =>'right',
          'width'     => '50px',
          'index'     => 'first_name',
           'align'     => 'left',
      ));


     $this->addColumn('is_active', array(
          'header'    => Mage::helper('approval')->__('Is Active'),
          'align'     =>'center',
          'index'     => 'is_active',
          'type'      => 'text',
          'width'     => '150px',
          'align'     => 'left',
          'filter'    => FALSE

      ));


      return parent::_prepareColumns();
  }



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

  }
}

can anybody please help me to figure out what I am doing wrong here?

Thanks,

1 Answer 1

0

You have your Grid class defined as app/code/local/Siteadmin/Approval/Block/Adminhtml/Approval/View/View.php. If you take a look at the line where this error is coming from (line no. 66 in app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php), you can see that grid is kind of hard-coded in there as to be the last word of your grid class. Try with having your grid class renamed as app/code/local/Siteadmin/Approval/Block/Adminhtml/Approval/View/Grid.php.

Edit :

Just found this detailed explanation about the same issue : Fatal error: Call to a member function setSaveParametersInSession() on a non-object in aBlock\Widget\Grid\Container.php on line 66

This question might fall into Duplicate one !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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