Set focus on search field in a grid

Hy,

In a grid application, I would like to have cursor focus set on the first field of the search form.
I have tried to use sc_set_focus on refresh event with no luck.

Any idea ?

Thanks

Use inspector to know selector of search field, and try with.

echo '
<script>
   $( "selector" ).focus();
</script>
';

Thanks a lot

I’ve used plain javascript in the OnRefresh event :

$focus="<script> document.getElementById(‘SC_riferimento’).focus(); </script>";
echo $focus;

it does not work.

Any idea ?

Didn’t tried, but for Quick search for example, try:

$focus=’<script> $("#SC_fast_search_top").focus(); </script>’;
echo $focus

The trick is to postpone the focus once the page is fully loaded.

here is a code that works:

echo “<script>document.addEventListener(‘DOMContentLoaded’, function() {document.getElementById(‘SC_riferimento’).focus();}, false);</script>”;

you can also try using the getelementsbyname method. I’ve found that in scriptcase generated code getelementbyid not always works.

regards