3

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?

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

});
Sign up to request clarification or add additional context in comments.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.