views:

1763

answers:

1

Hi all,

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?

Thanks in advance

+2  A: 
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();
   });

});
hunter
Thanks! i had a follow up question. "<%=ResolveUrl("~/one/folder/deeper/") %>?record=" + $(this).attr("RecordId");How would i get the value if there was no attribute for the RecordId?Suppose it was a dynamically generated table and i wanted the value of cell 1 or cell 2 for the row?Thanks
zSysop