开发者

jqgrid : how to change the class of one cell (when mouse is over on)?

I set cells of the first column of my grid, with a class as follows:

$("#myGrid").jqGrid('setCell',rowid,'column_1', '', '**ui-state-default**');

How can I change the class of a cell when the mouse is ov开发者_如何学Cer it?


How about this?

$("#myGrid").hover(function(){
        $(this).find("td:first").css("background-color", "black");
    });

EDIT

 $("#myGrid tr").hover(
              function(){
              $(this).find("td:first").addClass('ui-state-hover');
              },
              function(){
              $(this).find("td:first").removeClass('ui-state-hover');
              }   
            );

OR

$("#myGrid tr").mouseenter(function(){
      $(this).find("td:first").addClass('ui-state-hover');
    }).mouseleave(function(){
      $(this).find("td:first").removeClass('ui-state-hover');
    });


I solved it with something like this:

$("#myGrid tr").hover(function() { 
    $(this).find("td").eq(1).addClass('ui-state-hover');
});

$("#myGrid tr").mouseout(function() {
    $(this).find("td").eq(1).removeClass('ui-state-hover')
});

What do you think about?


Here is my last solution. I will use it as follows:

$("#mygrid tr").hover(
  function(){
      $(this).find("td").eq(1).removeClass('ui-state-default');
      $(this).addClass("ui-state-hover");
  },
  function(){
     if(!$(this).hasClass("ui-state-active"))
     $(this).find("td").eq(1).addClass('ui-state-default');
  }
);

$("#mygrid tr").click(function(){
  $("#mygrid tr").each(function() {
    $(this).find("td").eq(1).addClass('ui-state-default');
  });

  $(".ui-state-active").removeClass("ui-state-active");
  $(".ui-state-highlight").removeClass("ui-state-highlight");
  $(this).find("td").eq(1).removeClass('ui-state-default');
  $(this).addClass("ui-state-active");
});

It works well also for a grid within input text tags!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜