Sorting Gridview client side

 

jquery table sort plugin http://tablesorter.com

Asp.net gridview don’t output <thead> so tablesorter does not work. ¬†Use the follow jquery to fix the gridview tables to work with table sort. This will update all table with the style .gridStyle to be sortable.

 

<script type=”text/javascript”>
$(document).ready(function () {
//change gidview header cells td’s to th’s
$(‘.gridStyle’).prepend($(‘<thead></thead>’).append($(‘.gridStyle tr:first’).remove()));
$(“.gridStyle”).tablesorter({ widgets: [‘zebra’] });
}
);
</script>