사용자 정의 그리드 검색이 404 페이지로 리디렉션됩니까?
-
12-12-2019 - |
문제
모든 CMS 블록을 표시하는 사용자 정의 그리드가 있습니다.제목을 필터링하기 위해 그리드의 검색 창을 사용하면 404 페이지로 리디렉션됩니다.알 수 없는 페이지로 리디렉션되도록 하는 그리드에 문제가 있습니까?
또한 이것이 중요한지 확실하지 않지만 이는 Enterprise Edition 1.12에서 발생합니다.EE-1.13이라는 또 다른 인스턴스가 있는데 이는 문제가 되지 않습니다.
class TP_CustomApp_Block_Adminhtml_Glcmsblock_Grid extends Mage_Adminhtml_Block_Widget_Grid {
public function __construct() {
parent::__construct();
$this->setId('glcmsblockGrid');
$this->setDefaultSort('entity_id');
$this->setDefaultDir('DESC');
$this->setSaveParametersInSession(true);
$this->setVarNameFilter('product_filter');
}
protected function _prepareCollection() {
$store = $this->getRequest()->getParam('store', '');
Mage::getSingleton('core/session')->unsObjectType();
Mage::getSingleton('core/session')->setObjectType(‘cms/block’);
$collection = Mage::getModel('cms/block')->getCollection()->addStoreFilter($store->getId());
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns() {
$this->addColumn('title', array(
'header' => Mage::helper('cms')->__('Title'),
'align' => 'left',
'index' => 'title',
'width' => '25%',
));
$this->addColumn('identifier', array(
'header' => Mage::helper('cms')->__('Identifier'),
'align' => 'left',
'index' => 'identifier',
'width' => '20%',
));
…
return parent::_prepareColumns();
}
public function getGridUrl() {
return $this->getUrl('*/*', array('_current' => true));
}
public function getRowUrl($row) {
return '"';
}
protected function _prepareMassaction() {
$this->setMassactionIdField('entity_id');
$this->getMassactionBlock()->setFormFieldName('gl_block_ids[]');
$this->getMassactionBlock()->addItem('add', array(
'label' => ‘Do some stuff’,
'url' => $this->getUrl('*/*/massAdd'),
));
return $this;
}
}
제어 장치:
class TP_CustomApp_Adminhtml_GlcategoryController extends Mage_Adminhtml_Controller_Action {
public function indexAction() {
$this->loadLayout();
$this->_setActiveMenu(‘MyApp/do_something’);
$this->renderLayout();
}
public function gridAction(){
$this->loadLayout();
$this->getResponse()->setBody(
$this->getLayout()->createBlock('MyApp/adminhtml_glcategory_grid')->toHtml()
);
}
public function filterAction() {
$post = $this->getRequest()->getPost();
$radio = $post['filter'];
Mage::getSingleton('core/session')->unsCategoryFilter();
Mage::getSingleton('core/session')->setCategoryFilter($radio);
$store = $post['store_id'];
if ($store != '') {
$this->_redirect('MyApp/adminhtml_glcategory', array('_query' => array('store' => $store)));
return $this;
}
else {
$this->_redirect('*/*');
return $this;
}
}
public function massAddAction() {
$post = $this->getRequest()->getPost();
$selected_category_ids = $post['gl_category_ids'];
if (count($selected_category_ids) > 0) {
// do some stuff with the ids
return $this;
}
else {
Mage::getSingleton('adminhtml/session')->addError('Please select a record.');
$this->_redirect('*/*');
return $this;
}
}
}
해결책
작업 이름이 누락되었습니다. getGridUrl()
방법
public function getGridUrl() {
return $this->getUrl('*/*/grid', array('_current' => true));
}
편집하다 :당신의 변경 gridAction()
아래와 같이
public function gridAction(){
$this->loadLayout();
$this->renderLayout();
}
제휴하지 않습니다 magento.stackexchange