简体   繁体   English

Yii CGridView过滤器

[英]Yii CGridView Filter

I want CGridView's filter to work with multiple words in one column at the time. 我希望CGridView的过滤器能够在一列中处理多个单词。 For example i want to show all rows with "A" in first column plus all the rows with "B" in the same column. 例如,我想显示第一列中带有“A”的所有行以及同一列中带有“B”的所有行。

Does anybody know which class and function should i override to do this? 有人知道我应该覆盖哪个类和函数来执行此操作吗?

You will have to modify the search() function in your model. 您必须修改模型中的search()函数。 The search() function will have something like this - search()函数会有这样的东西 -

    $criteria->compare('your_column_name', $this->your_column_name, true);

you can modify it by breaking the input, which is in $this->your_column_name and adding one compare condition for each of the elements in the input. 您可以通过断开输入来修改它,该输入位于$ this-> your_column_name中,并为输入中的每个元素添加一个比较条件。 You can use explode() to break the string into multiple terms. 您可以使用explode()将字符串分解为多个术语。

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

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