Thursday, June 7, 2012

Solution for Grid view sorting at client side instead of Server side

Recently during the code review I have identified the performance issue Grid view Server side sorting . To avoid the server side sorting I have implemented

client side sorting using jQuery plugin. Here is the implementation steps for Client side sorting.

Step#1

=>Download the tablesorter plugin min JavaScript and place into script folder

=>Add the reference to sorting required page

Ex:

<script src="../Scripts/jquery.tablesorter.min.js" type="text/javascript"></script>

Add this script into JavaScript block



$(document).ready(function () {
$("#ctl00_ContentPlaceHolder_gvMyStyles").tablesorter(); 
});

Step#2

Place these two lines of code after the gridview bind



gvMyStyles.UseAccessibleHeader = true;  
gvMyStyles.HeaderRow.TableSection = TableRowSection.TableHeader;