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,