1

我在 magento admin 中创建了一个自定义模块。问题是grid.phpMage_Adminhtml_Block_Widget_Grid扩展不显示网格(仅显示按钮和标题文本)。grid.php 的内容:

class Ha_Hvdmodule_Block_Adminhtml_Information_Grid extends Mage_Adminhtml_Block_Widget_Grid{
public function _construct(){
    parent::_construct();
    $this->setId('informationGrid');
    $this->setDefaultSort('id');
    $this->setDefaultDir('ASC');
    $this->setSaveParametersInSession(true);
}

protected  function _prepareCollection(){
    $collection = Mage::getModel('hvdmodule/information')->getCollection();
    $this->setCollection($collection);
    return parent::_prepareCollection();
}

protected function _prepareColumns(){
    $this->addColumn('id', array(
        'header' => Mage::helper('hvdmodule')->__('ID'),
        'align' => 'right',
        'width' => '10px',
        'index' => 'id',
    ));

    $this->addColumn('name', array(
        'header' => Mage::helper('hvdmodule')->__('Name'),
        'align' => 'left',
        'width' => '15px',
        'index' => 'name',
    ));

    $this->addColumn('content', array(
       'header' => Mage::helper('hvdmodule')->__('Content'),
        'align' => 'left',
        'width' => '20px',
        'index' => 'content',
    ));

    return parent::_prepareColumns();
}
}


?>

内容布局:

<?xml version="1.0"?>
 <layout>
 <hvdmodule_adminhtml_information_index>
    <reference name="content">
        <block type="hvdmodule/adminhtml_information" name="information"/>
    </reference>
</hvdmodule_adminhtml_information_index>
</layout>

内容控制器:

class Ha_Hvdmodule_Adminhtml_InformationController extends Mage_Adminhtml_Controller_Action{

public function indexAction(){
    $this->loadLayout();
    $this->renderLayout();
}

}

4

1 回答 1

0

您是否将信息块设置为容器?

class Ha_Hvdmodule_Block_Adminhtml_Information extends Mage_Adminhtml_Block_Widget_Grid_Container 
{
    public function __construct()
    {        
        $this->_controller = 'adminhtml_information';
        $this->_blockGroup = 'information';

        $this->_headerText = Mage::helper('module')->__('title');
        $this->_addButtonLabel = Mage::helper('module')->__('Add Item');

        parent::__construct();
    }
}
于 2013-06-12T16:05:45.560 回答