Start refined search whith any value

Hello…
I have a grid, with a refined search, with four fields (date, status and action).
How i can set, when open the grid, to set one of this filters in any value? By example, status = ‘P’
Thanks!!!

I did it but it’s not a clean solution.
It’s usable only if you know you are going to filter for a very limited and known set of values (e.g. “yes”, “no”), as the values are hardcoded in the code.
Hopefully someone have a better solution.

Anyway, see my code below.
From the calling app I pass to the grid either nothing, to have the grid with no search applied, or [param_filter_to_apply] set in my case to ‘by_status_wip’ or ‘by_alert_defcon_1’, to have the refined search applied accordingly.
The [param_filter_to_apply] strings to pass between the calling app and the grid app cab be set arbitrarily;
what is important and must match how SC will actually apply the refined search are the $p1, $p2 and P3 variables.
You have to hover over the refined search in you running grid app: look how the nm_proc_int_search() js function’s parameters are populated in your case to see how to set the $p1, $p2 and P3 variables in the code below.

OnFooter of the grid app:

  $apply_filter = false;
  switch ([param_filter_to_apply])
  {
      case "by_status_wip":
        $p1="Stato";
          $p2="internal_status_name";
          $p3="Work in progress##@@Work in progress";
          break;
      case "by_alert_defcon_1":
          $p1="Alert Scadenze RDO";
          $p2="deadline_alert_level";
          $p3=get_id_alert_level_from_defcon(1);
          break;
  }
  
  if ($apply_filter)
  {
      echo "<script>nm_proc_int_search('link','tx','$p1','$p2','$p3', '$p2', '')</script>";
      sc_reset_global([param_filter_to_apply]);
  }
 

Thanks!!! I Try!

Sorry… what are the parameters of nm_proc_int_search?

Thanks!!!

You have to find out on your running grid.
Hover with the mouse over the refined search values; if your browser is showing, in the status bar, the link that will be “executed” on click, it will show the nm_proc_int_search() function with the parameters populated differently for each refined search value.
Alternatively you could inspect the page code.

E.g. as you can see in this picture, when I move the mouse over the “No” refined search option, chrome will show the complete js funcioin in its status bar (bottom left),

[ATTACH=CONFIG]n82272[/ATTACH]

sc_ref_search.jpg

Tanks!!! Work!!

Solved!!!
I find the sintax of nm_proc_int_search how explain Robydago…
Then, in Layout, footer, in a line select “Value”, and in the value, paste <script>javascript:nm_proc_int_search(‘link’,‘tx’,‘Estado’,‘emb_estado’,‘P##@@En%20Espera’,‘emb_estado’,’’)</script>
(the link show in the statusbar, whith the tags <script> and </script>
Toggle footer to show… compile… and work fine!!!
Thanks

I’m @ SC9, no javascipt work onFooter of grid :frowning:

Try to use onRecord, but control the loops using variable. Like:
if([first]){
[first] = false;
echo “”;
}

what Felipe said works for me, so when I open the grid it is filtered, but after that I can filter as I want,
very good Felipe :grinning:!

1 Like

This is great! Thank you! But it does not work when you add a group by to the grid. Anyone know how to resolve that?