Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selectable Table Row Jquery Asp.net

I would like to create a table where the rows are selectable via jquery. I'd also like to pass certain table cell values from a double click event on a row to another page.

Does any one have examples of how this would work?

like image 837
zSynopsis Avatar asked Dec 06 '25 17:12

zSynopsis


1 Answers

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

});
like image 153
hunter Avatar answered Dec 08 '25 10:12

hunter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!