I have a standard grid filled with a collection, which is filterable.
I would like to be able to search in the filtered resultset of that grid, so I can redirect the edit form to the next item without returning to the grid.
For what it’s worth, the grid code:
class Phpro_Advancedtranslate_Block_Adminhtml_Grid extends Mage_Adminhtml_Block_Widget_Grid {
public function __construct() {
parent::__construct();
$this->setId('advancedtranslateGrid');
$this->_controller = 'advancedtranslate';
$this->setDefaultSort('advancedtranslate_id');
$this->setDefaultDir('ASC');
$this->setSaveParametersInSession(true);
$this->setUseAjax(true);
}
protected function _prepareCollection() {
$model = Mage::getModel('advancedtranslate/advancedtranslate');
$collection = $model->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns() {
$this->addColumn('advancedtranslate_id', array(
'header' => Mage::helper('advancedtranslate')->__('ID'),
'align' => 'right',
'width' => '50px',
'index' => 'advancedtranslate_id',
));
$this->addColumn('string', array(
'header' => Mage::helper('advancedtranslate')->__('String'),
'align' => 'left',
'width' => '150px',
'index' => 'string',
'type' => 'text',
'truncate' => 50,
'escape' => true,
));
$localesSourceModel = Mage::getModel('advancedtranslate/system_config_source_locales');
$localesOptions = $localesSourceModel->toArray();
$this->addColumn('locale', array(
'header' => Mage::helper('advancedtranslate')->__('Locale'),
'align' => 'left',
'index' => 'locale',
'type' => 'options',
'escape' => true,
'options' => $localesOptions
));
$modulesSourceModel = Mage::getModel('advancedtranslate/system_config_source_modules');
$modulesOptions = $modulesSourceModel->toArray();
$this->addColumn('module', array(
'header' => Mage::helper('advancedtranslate')->__('Module'),
'align' => 'left',
'index' => 'module',
'type' => 'options',
'escape' => true,
'options' => $modulesOptions
));
$interfaceSourceModel = Mage::getModel('advancedtranslate/system_config_source_interface');
$interfaceOptions = $interfaceSourceModel->toArray();
$this->addColumn('interface', array(
'header' => Mage::helper('advancedtranslate')->__('Interface'),
'align' => 'left',
'index' => 'interface',
'type' => 'options',
'escape' => true,
'options' => $interfaceOptions
));
$storeSourceModel = Mage::getModel('advancedtranslate/system_config_source_stores');
$storeOptions = $storeSourceModel->toArray();
$this->addColumn('store_id', array(
'header' => Mage::helper('advancedtranslate')->__('Store view'),
'align' => 'left',
'index' => 'store_id',
'type' => 'options',
'escape' => false,
'options' => $storeOptions
));
$this->addColumn('action', array(
'header' => Mage::helper('advancedtranslate')->__('Action'),
'width' => '150px',
'type' => 'action',
'getter' => 'getAdvancedtranslateId',
'actions' => array(
array(
'caption' => Mage::helper('advancedtranslate')->__('Edit'),
'url' => array(
'base' => '*/*/edit'
),
'field' => 'id'
),
array(
'caption' => Mage::helper('advancedtranslate')->__('Delete'),
'url' => array(
'base' => '*/*/delete'
),
'field' => 'id'
)
),
'filter' => false,
'sortable' => false
));
return parent::_prepareColumns();
}
public function getRowUrl($row) {
return $this->getUrl('*/*/edit', array(
'id' => $row->getAdvancedtranslateId(),
));
}
public function getGridUrl() {
return $this->getUrl('*/*/grid', array('_current' => true));
}
}
More than likely if I’m understanding your question correctly you’ll want to save an array of IDs from the filtered results in the session.
how do i save array in magento session?
And then retrieve the next ID from the Array you saved in the session to proceed to the next ID in the filtered results set.