2

I am retrieving data from sql server into DataTables and needing a way to click on the table row to access more information. Here is my javascript:

$(function () {
  $("[id*=tblAccount]").prepend($("<thead></thead>").append($(this).find("tr:first"))).DataTable({
    "paging": true,
    "lengthChange": true,
    "searching": true,
    "ordering": true,
    "info": true,
    "autoWidth": true,
    "responsive": true,
    "dom": 'lBfrtip',
    "buttons": ['excel', 'print', 'pdfHtml5'],        
  });
})
<asp:GridView ID="tblAccount" runat="server" AutoGenerateColumns="false" CssClass="table table-bordered table-striped">
  <Columns>
    <asp:BoundField DataField="ACCOUNT_NUMBER" HeaderText="Account Number" />
    <asp:BoundField DataField="COMPANY_NAME" HeaderText="Tax Type" />
  </Columns>
</asp:GridView>

How can I click on the table row to access another page?

2 Answers 2

1

As far as I understood the question, you may simply attach event handler to DataTable rows, like so:

$('table tbody tr').on('click',function(){
    //retrieve your extra details
});

However, I'd rather suggest to use DataTables embedded feature to display extra details inline: https://datatables.net/examples/api/row_details.html

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

1 Comment

Thank you! Your suggestion to display external details inline is just what I needed.
1

you can write click event like this also.

$(document).on('click','table tbody tr',function(){
    //code here
});

Comments

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.