2009-03-16 8 views
3

jqueryで行を選択できるテーブルを作成したいと考えています。 また、ある行のダブルクリックイベントから特定の表のセル値を別のページに渡したいと思います。選択可能なテーブル行Jquery Asp.net

これはどのように動作するのでしょうか?

答えて

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(); 
    }); 

}); 
+0

ありがとうございました!私はフォローアップの質問をしました。 "<%= ResolveUrl("〜/ one/folder/deeper/")%>?record =" + $(this).attr( "RecordId"); RecordIdの属性がない場合、どのように値を取得できますか? 動的に生成されたテーブルで、行のセル1またはセル2の値が必要だったとしますか? ありがとう – zSynopsis

関連する問題