Magento - 在过滤后的网格结果中搜索

时间:2011-10-31 14:34:42

标签: magento filter grid

我有一个标准网格,里面有一个可过滤的集合。

我希望能够搜索该网格的过滤结果集,这样我就可以将编辑表单重定向到下一个项目,而无需返回到网格。

对于它的价值,网格代码:     

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));
}

}

1 个答案:

答案 0 :(得分:1)

如果我正确理解您的问题,您很可能会想要从会话中的过滤结果中保存一系列ID。

how do i save array in magento session?

然后从会话中保存的数组中检索下一个ID,以继续过滤结果集中的下一个ID。