Filter a column by multiple values

QuestionsFilter a column by multiple values
Ty asked 8 years ago

I have a column called arrows. The cell values are up, down, left, right and equal.

Filter one value is no problem.

How can we filter to more than one value, in example: up and left, or up and even?

Thank you!

4 Answers
Abu Ghufran answered 8 years ago

Using autofilter, You can set "IN" as search operator and use comma to filter multiple values.
You need to set:
$col["searchoptions"]["sopt"] = array("in");

Using search dialog in menu, you can add multiple conditions with OR operator.
$g->set_actions(array(
…..
"search" => "advance",
)
);

santosh answered 8 years ago

I would like to search for a comma separated list too. I tried code below but does not work. What is sopt?

$col = array();
$col["name"] = "names";
$col["title"] = "names";
$col["width"] = "100";
if (editGrid != 'NO'){
$col["editable"] = true;
$col["searchoptions"]["sopt"] = array("in");
}
$cols[] = $col;

santosh answered 8 years ago

I am looking for search to return results for a comma seperated list of values, example: john,tom,mick

Is this possible using the above option and if yes, how to use this? are there any examples?

Abu Ghufran answered 8 years ago

This should work.

$col = array();
$col["title"] = "Total";
$col["name"] = "total";
$col["width"] = "50";
$col["editable"] = true;
$col["searchoptions"]["sopt"] = array("in");
$cols[] = $col;

To test, paste this code in demos/appearance/alternate-row.php
https://gist.github.com/gridphp/97fdc89b0e8ddb5f30d7

And in autofilter, type "1,120"
It will filter both data records.

Your Answer

14 + 9 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?