Tip: Make the search_text auto-update the filter or use filter on Enter keypress

Hi,

I just want to share my findings about the search box in a GRC table view.

Wanted to have the list updates immediately or after Enter key is pressed in the search box. I used a custom view, so it does not interfere with existing files:

Just after the existing html code and before the <?php tag insert this:

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

    <script type="text/javascript">
        $( document ).ready(function(){
            $("#search_text").keyup(function(event){
                //alert("there is a keyup");
                if(event.which==13)
                    $( '#crud_search' ).click ();
            });
        });
    </script>

Now, if you press the Enter after the chars typed in the search box, the filter will be applied to the list. No need to click the search button.

The above can also be changed to update the filtered list on every keystroke by removing the if line.

        $( document ).ready(function(){
            $("#search_text").keyup(function(event){
                //alert("there is a keyup");
                //if(event.which==13)
                    $( '#crud_search' ).click ();
            });
        });

Thanks to all helping with GRC

regards

Josef