Mage Register is Cleared by Grid Search Button No Page Reload
Question
Even though there is no page reload, and grid ajax is set to true, the Mage::registry gets cleared when the grid search button is clicked.
I am using a registry variable related to an option type in the grid.
Is there a way to avoid the registry getting cleared in this scenario?
class MyModule_Block_Adminhtml_MyGrid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setTemplate('mymodule/mymodel/meter/grid.phtml');
$this->setId('time_settings');
$this->setDefaultSort('sort_order');
$this->setDefaultDir('ASC');
$this->setSaveParametersInSession(true);
$this->setUseAjax(true);
}
....
public function getGridUrl()
{
return $this->getUrl('*/*/metergrid', array('_current'=>true));
}
Solution
registry does not mean session.
A value placed in registry acts somehow as a global variable. It is available everywhere in the current request.
An AJAX call is a totally different request.
If you need some value from the initial request in your ajax call you should store that value in session.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange