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 に答える