Magento - 网格分页

标签 magento gridview pagination

我在 magento 后端创建了网格,但分页不起作用。无论我选择每页多少条记录,页面上始终显示所有记录。现在我在数据库中有 41 条记录,网格上方的“统计信息”没问题(找到的页数和记录数):

Page 1 of 3 pages | View 20 per page | Total 41 records found

哪个文件负责分页? 按特定列排序还有另一个问题。对于前。记录的显示方式与我选择按 ID 排序的 ASC 或 DESC 顺序相同...

网格:

public function __construct() {
        parent::__construct();

        $this->setId('logger_grid');
        $this->setUseAjax(FALSE);
        $this->setDefaultSort('id');
        $this->setDefaultDir(Varien_Data_Collection::SORT_ORDER_ASC);
        $this->setSaveParametersInSession(TRUE);
    }

    public function _prepareCollection() {
        $collection = Mage::getModel('logger/logger')->getCollection()->load();
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }

    public function _prepareColumns() {
        $this->addColumn('id', array(
            'header' => Mage::helper('logger')->__('ID'),
            'sortable' => TRUE,
            'index' => 'log_id',
            'editable' => FALSE,
        ));

        $this->addColumn('interface', array(
            'header' => Mage::helper('logger')->__('Interface'),
            'sortable' => TRUE,
            'index' => 'interface',
            'editable' => FALSE,
        ));

        $this->addColumn('type', array(
            'header' => Mage::helper('logger')->__('Type'),
            'sortable' => TRUE,
            'index' => 'type',
            'editable' => FALSE,
        ));

        $this->addColumn('description', array(
            'header' => Mage::helper('logger')->__('Description'),
            'sortable' => TRUE,
            'index' => 'description',
            'editable' => FALSE,
        ));

        $this->addColumn('message_data', array(
            'header' => Mage::helper('logger')->__('Message'),
            'sortable' => TRUE,
            'index' => 'message_data',
            'editable' => FALSE,
        ));

        $this->addColumn('time', array(
            'header' => Mage::helper('logger')->__('Time'),
            'sortable' => TRUE,
            'index' => 'time',
            'editable' => FALSE,
            'type' => 'datetime',
        ));

        return parent::_prepareColumns();
    }

    public function getRowUrl($row) {
        return $this->getUrl('*/*/edit', array('id' => $row->getId()));
    }

集合.php:

public function _construct(){
    $this->_init("logger/logger");
}

最佳答案

好的,问题解决了。一如既往只是一件小事......在 _prepareCollection() 函数中我使用 $collection = Mage::getModel('logger/logger')->getCollection()->load(); 分页因为 load() 不起作用功能。

感谢您的回复,sparcksoft :)

关于Magento - 网格分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11954393/

相关文章:

inheritance - 继承catalog.xml中magento中的类别布局更新

magento - 使用产品 ID 在 Magento 中获取大集合的产品 sku

asp.net - 使用 FindControl 获取内容页中的 GridView

asp.net-mvc - 是否有在数据库中进行分页的 ASP.NET MVC 分页解决方案?

javascript - Canvas 图像未在站点中显示

magento - Magento中的独立读写数据库

android - GridView 中每个项目的不同高度

asp.net - 为 ASP.NET 网站创建 DAL

javascript - Angular 应用程序提取整个集合,而不是预期的有限数量的结果

javascript - 工具提示不适用于数据表上的分页