我在同一模块中有2个网格(我需要将它们保存在同一个模块中)。 当我点击列的顶部时,网格会将自身加载到其自身内。
以下是我的代码: Myname_Blink_Adminhtml_BlinkController
public function keywordsAction()
{
$this->loadLayout();
$this->_setActiveMenu('blink/keywords');
$this->_addContent($this->getLayout()->createBlock('Myname_Blink_Block_Adminhtml_Keywords_Grid'));
$this->renderLayout();
}
我的阻止文件:Myname_Blink_Block_Adminhtml_Keywords_Grid extends
class Myname_Blink_Block_Adminhtml_Keywords_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('keywords_grid');
$this->setDefaultSort('keywords_id');
$this->setDefaultDir('ASC');
//$this->setSaveParametersInSession(true);
$this->setUseAjax(true);
}
根据这篇文章的建议:Multiple grid in Magento admin
我删除了文件: => Myname_Blink_Block_Adminhtml_Keywords =>应用\设计\ adminhtml \默认\默认\布局\ MYNAME \ blink.xml
答案 0 :(得分:1)
AJAX调用可能出现问题 你试过这个吗: http://davemacaulay.com/fix-issue-with-magento-adminhtml-grid-ajax-call-containing-the-whole-page/
public function keywordsAction()
{
if($this->getRequest()->isXmlHttpRequest()) {
$this->getResponse()->setBody($this->getLayout()->createBlock('Myname_Blink_Block_Adminhtml_Keywords_Grid')->toHtml());
return $this;
}
$this->loadLayout();
$this->renderLayout();
}
祝你好运!!!