简体   繁体   English

Yii-CGRIDVIEW分页上的其他参数

[英]Yii - CGRIDVIEW Additional parameters on pagination

To make it easy, I have a GridView and I have to pass more parameters to the Ajax Call when I change page. 为了简单起见,我有一个GridView,并且在更改页面时必须将更多参数传递给Ajax调用。 The default parameters are: 默认参数是:

  • current controller; 电流控制器
  • page number; 页码;
  • ajaxVar (default ajax) with the grid id as default; ajaxVar(默认ajax),其网格ID为默认值;

I need to pass more parameters because the controller needs more parameters to recreate the correct grid. 我需要传递更多参数,因为控制器需要更多参数才能重新创建正确的网格。

On google I have found no answer. 在Google上,我没有找到答案。

Any advice? 有什么建议吗?

Thanks! 谢谢!

Yii is extremly extendable, so you can create a Custom Pagination Widget. Yii具有极好的可扩展性,因此您可以创建“自定义分页小部件”。 Firstly, have a look at this tutorial: 首先,请看一下本教程:

How to create a Custom Pagination Widget for Yii Framework 如何为Yii框架创建自定义分页小部件

Here is example from our Project for createPageButton() function in extended Pagination: 这是扩展分页中的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));
}

Take a look at following code line: 看一下下面的代码行:

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

Url Attribute is &pageSize= , and you can extend to any parameters you need with ie . '&myParameter=any_parameter' 网址属性是&pageSize= ,您可以使用ie扩展到所需的任何参数. '&myParameter=any_parameter' . '&myParameter=any_parameter'

This is definitely the way you can solve your problem and I hope it will help you. 这绝对是您解决问题的方式,希望对您有所帮助。 If you have any questions, feel free to ask. 如果你有任何问题随时问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM