Filter expressions

QuestionsFilter expressions
Gary Michael Wilson asked 3 years ago

I have a column that has, for example, values such as “SE”, “SE Technology”, “SE L” and I want to filter down to rows that contain just “SE”. But I get all the above if I filter on “SE” as it is a substring. What syntax do I need to enter to get just “SE” rows? I tried to find some “filter user guide”.

Thanks

2 Answers
Mike answered 3 years ago

A couple of options.

The default criteria cn (contains). You could modify the default search to be eq (equal), or use the magnifying glass which gives you the option to choose the criteria (contains, equals, does-not equal) in the advanced search.

Each column can have a default setting if you want to configure the search-options. See example below from another post by Abu:

The Demos have some very good examples of more advanced searching with forms as well.

Thanks

Mike

————–8< ————-

(e.g. bw = begins with, ‘eq’,’ne’,’lt’,’le’,’gt’,’ge’,’bw’,’bn’,’in’,’ni’,’ew’,’en’,’cn’,’nc’)

$col[“searchoptions”][“sopt”] = array(“cn”,”bw”); // only show contains and beginswith with first as default.
$cols[] = $col;

 

Abu Ghufran Staff answered 3 years ago

To limit search with exact match, you can set:

$col["searchoptions"]["sopt"] = array("eq");

Another way is to use dropdown filter.

https://www.gridphp.com/demo/demos/search/filter-row.php
https://www.gridphp.com/demo/demos/search/filter-row.phps line 64-70

You can also set hardcoded values in search dropdown if don’t want it from db.
https://www.gridphp.com/docs/column-options/#render-as-select-dropdown

e.g.

$col["searchoptions"] = array("value" => '10:$10;20:$20;30:$30;40:$40;50:$50');

Docs ref: https://www.gridphp.com/docs/column-options/#dropdown-in-filter-row

PS: Thanks Mike.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

3 + 14 =

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?