Implement javascript sorting as asp.net grid

How to sort gridview in client browser using javascript? without using the built-in grid sorting method. I really don't want gridview to access the database every time it is sorted.

+3
source share
1 answer

Try jQuery tablesorter plugin

<script type="text/javascript" src="/path/to/jquery-latest.js"></script> 
<script type="text/javascript" src="/path/to/jquery.tablesorter.js"></script>

....

<script type="text/javascript">
    var aspxElements = {
        theGrid: '<%= myGrid.ClientID %>' //I'm not entierly sure this is the id of the table or some container element
    };

    $(document).ready(function() { 
        $('#' + aspxElements.theGrid).tablesorter(); 
    });
</script>

(modified from the demo on this page )

Please note that this will be strange if you use pagination.

+3
source

Source: https://habr.com/ru/post/1733133/


All Articles