Search code examples
phpjqxgrid

How to track filter events in jqxgrid


I am working with jqxgrid and PHP. In the jqxgrid i have problem with filter functionality. I want to know that is there any function that show me what filterting options i selected for filtering data.

I have a section below jqxgrid table. In which i want a some calculation based on that jqxgrid table data. When the user load a page firsttime then jqxgrid data and below calculations are correct. But when user make some filterization in jqxgrid table below calculation does not change. I want what filter options choose by user for filtering operation.

Is there any way to do that?


Solution

  • After digging lot in the jqxgrid documentation, I found the answer that how to get filterable data from grid table.

    Basically jqxgrid provide this method for getting current table data.

    var rows = $('#jqxgrid').jqxGrid('getdisplayrows');
    

    You can use this method in your filter functionality and will get the filterable result.

    $("#jqxgrid").bind("filter", function (event) {
                $("#jqxgrid").jqxGrid('autoresizecolumns');
                var rows = $('#jqxgrid').jqxGrid('getdisplayrows');
                showResults(rows);
            });
    

    Now create a showResults() function in like this way.

    <script>
    function showResults(data) {
    console.log(data);
    // Do anything you want to do with current table data.
    }
    </script>