Hello,
Is it possible to show the grid data only on search or filter.
Thank you
Dumitri
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
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.
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
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.