[英]Yii - CGRIDVIEW Additional parameters on pagination
为了简单起见,我有一个GridView,并且在更改页面时必须将更多参数传递给Ajax调用。 默认参数是:
我需要传递更多参数,因为控制器需要更多参数才能重新创建正确的网格。
在Google上,我没有找到答案。
有什么建议吗?
谢谢!
Yii具有极好的可扩展性,因此您可以创建“自定义分页小部件”。 首先,请看一下本教程:
这是扩展分页中的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=
,您可以使用ie扩展到所需的任何参数. '&myParameter=any_parameter'
. '&myParameter=any_parameter'
这绝对是您解决问题的方式,希望对您有所帮助。 如果你有任何问题随时问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.