jqGrid zebra striping problem

Posted by ShiVik on Stack Overflow See other posts from Stack Overflow or by ShiVik
Published on 2010-06-08T10:17:02Z Indexed on 2010/06/08 10:22 UTC
Read the original article Hit count: 411

Filed under:
|

Hello all

I have just started with jQuery. I am trying to implement zebra striping in my jqGrid class. I am having the problem when user clicks on sort column, all rows get rearranged and the zebra striping is blown away.

Zebra Striping code

$("#item_table tbody tr:odd").addClass("alt"); $("#item_table tbody tr").mouseover(function() { $(this).addClass("over"); }); $("#item_table tbody tr").mouseout(function() { $(this).removeClass("over"); });

jqGrid code

jQuery.extend(jQuery.jgrid.defaults, {
  autowidth: true,
  hidegrid: false,
  colModel:[
   { name: 'icon', index: 'icon', width: 0, resizable: false },
   { name: 'name', index: 'name', width: 0, resizable: false },
   { name: 'price', index: 'price', width: 0, sorttype: "int", resizable: false }
  ],
  onSortCol: function(index, iCol, sortorder) {
                 // This doesn't work - IT SHOULDN'T EITHER, since event is called 
                 // just after clicking to sort but before actual sorting
                 jQuery("#item_table tbody tr:odd").addClass("odd");
  },
  caption: "Item Table"
 });

I also tried loadComplete, gridComplete events, but to no avail.

How should I proceed with this? Have I even started this right?

Regards Vikram

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jqgrid