Yii - CGRIDVIEW关于分页的其他参数

时间:2017-03-20 15:33:19

标签: php ajax yii

为了方便起见,我有一个GridView,当我更改页面时,我必须将更多参数传递给Ajax Call。默认参数为:

  • 电流控制器;
  • 页码;
  • ajaxVar(默认ajax),网格ID为默认值;

我需要传递更多参数,因为控制器需要更多参数来重新创建正确的网格。

在Google上我找不到答案。

有什么建议吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

Yii是极端可扩展的,因此您可以创建自定义分页小组件。首先,看看本教程:

  

How to create a Custom Pagination Widget for Yii Framework

以下是扩展分页中我们的Project for createPageButton()函数的示例:

/**
 * Creates a page button.
 * You may override this method to customize the page buttons.
 *
 * @param string $label the text label for the button
 * @param integer $page the page number
 * @param string $class the CSS class for the page button. This could be 'page', 'first', 'last', 'next' or 'previous'.
 * @param boolean $hidden whether this page button is visible
 * @param boolean $selected whether this page button is selected
 * @return string the generated button
 */
protected function createPageButton($label, $page, $class, $hidden, $selected) {
    if ($hidden || $selected)
        $class .= ' ' . ($hidden ? 'disabled' : 'active');

    return CHtml::tag('li', array(
        'class' => $class
    ), CHtml::link($label, $this->createPageUrl($page).'&pageSize='.$this->pageSize));
}

看看下面的代码行:

CHtml::link($label, $this->createPageUrl($page).'&pageSize='.$this->pageSize)

网址属性为&pageSize=,您可以扩展为您需要的任何参数,例如. '&myParameter=any_parameter'

这绝对是您解决问题的方式,我希望它会对您有所帮助。如果您有任何疑问,请随时提出。

相关问题