1

I have an asp.net GridView that I use the tablesorter on:

  $(document).ready(function() {
     $("[id$='_myGridView']").tablesorter({ sortList: [[0, 0]] });
  }); 

How can I apply zebra striping that re-stripes when re-sorting?

Edit: As @Chetan Sastry pointed out, it's as simple as:

  $(document).ready(function() {
     $("[id$='_myGridView']").tablesorter({ sortList: [[0, 0]], widgets: ['zebra'] });
  }); 
chris
  • 36,094
  • 53
  • 157
  • 237

2 Answers2

2

Have you seen the zebra widget in tablesorter plugin? This says it is part of plugin core - http://tablesorter.com/docs/example-widgets.html

Chetan S
  • 23,637
  • 2
  • 63
  • 78
  • Don't forget with a gridview you may need to render the etc. for tablesorter to work, as seen in this post: http://stackoverflow.com/questions/3978990/how-can-i-use-jquery-tablesorter-with-an-asp-net-gridview – deebs Sep 18 '14 at 17:25
2

It looks like .tablesorter() applies classes of odd and even on the rows of your table. The CSS rule from the Tablesorter webpage is:

table.tablesorter tbody tr.odd td { background-color: #F0F0F6 }
awayken
  • 485
  • 3
  • 8