1

我在使用 Yii 搜索时遇到问题,直接访问页面(学生/管理员)时它工作正常,但是如果我从另一个页面(学生/注册)渲染部分相同页面,Yii 过滤器不会搜索结果..

提前致谢

4

2 回答 2

0

您必须actionRegStudentsController. 模型的这些值将被用于CGridView设置过滤器。

这可能是这样的:

public function actionReg($id) {
  $model = Students::model();
  $model->attributes = $_GET['Students'];

  $this->render('reg', array(
           'model' => $model,
        ));
}

如果您在模型中有自定义值,则还必须设置它们,例如

  $model->calculatedAverage = $_GET['Students']['calculatedAverage'];

然后在你的RegView你可以将这个模型传递给表。

要了解其工作原理,请尝试了解该adminAction方法中发生的情况。

于 2013-02-27T08:22:50.793 回答
0

如果我做对了,如果你没有正确使用它,renderPartial 不会处理内联 js。尝试做:

$this->renderPartial('view',array(...),false,true);

它应该有帮助。最后一个参数 ( true ) 告诉 Yii 处理输出。

于 2013-02-27T02:09:16.677 回答