Show the grid rows only on search or filter

QuestionsShow the grid rows only on search or filter
Dumitri Roon asked 1 year ago

Hello,

Is it possible to show the grid data only on search or filter.

Thank you

Dumitri

5 Answers
Dumitri Roon answered 1 year ago

Sorry if my question was not clear, I meant I need the grid data/rows to be shown after a search or filter, this will allow the user to see only the searched results/filter.

Thank you

Abu Ghufran Staff answered 1 year ago

Hi,

I’m still unclear what are you trying to achieve.

If you wish to load grid with a set of predefined filter, you can follow this:
https://www.gridphp.com/docs/search/#search-based-on-url-parameters

Second option, You can refer demos / search / search-onload to set preload filters.
https://www.gridphp.com/docs/search/#search-on-load

If you mean you want to show blank grid at first and then show results only when user do some searching, then try following grid options.

$opt["datatype"] = "local";
$opt["loadComplete"] = "function(){ $('#list1').jqGrid('setGridParam', { datatype: 'json' }); }";

where list1 is your grid id.
 

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Dumitri Roon answered 1 year ago

Hi,

Thank you for your reply, I already used this code to achieve the second option and the grid loaded successfully without data/rows, but the issue is that all the grid data/rows appear again after clearing the search/filter or press the refresh/reload button in the gird header.

I need the user to NOT be able to see all the grid data/rows in any circumstance, but only the searched/filtered data.

 

Kind regards
Dumitri

Abu Ghufran Staff answered 1 year ago

You can use this workaround, set $w as follow:

if ($_GET["_search"] == "false") $w = "WHERE 1=0"; else $w = "";

And in your select_command query append this $w, e.g.

$g->select_command = "SELECT * FROM invheader $w";

Explanation: Whenever search is not performed, it will append a false condition to the query that will give no result and will perform as expected in other case.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Dumitri Roon answered 1 year ago

Hi, it worked. thank you very much.

Your Answer

2 + 0 =

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?