3

我想创建一个可以通过 jquery 选择行的表。我还想将某些表格单元格值从一行上的双击事件传递到另一个页面。

有没有人有这将如何工作的例子?

4

1 回答 1

2
var selected = null;

$(document).ready(function(){
   $("#<%=myTable.ClientID %>").find("tr").click(function(){
      $(selected).removeClass("selected");
      $(this).addClass("selected");
      selected = this;
   });

   $("#<%=myTable.ClientID %>").find("tr").dblclick(function(){

      /* if you just want to dig into that record I would put a custom attribute on the row */
      window.location = "<%=ResolveUrl("~/one/folder/deeper/") %>?record=" + $(this).attr("RecordId");

      /* or you could have a hidden LinkButton in the row (Text="" or not set) that you could trigger. Make sure you set the CommandName="Something" and CommandArgument="RecordId" */
      $(this).find("a").click();
   });

});
于 2009-03-16T23:23:19.777 回答