Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7932319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:58:54+00:00 2026-06-03T20:58:54+00:00

I am basically trying to combine code from two examples given in the DataTables

  • 0

I am basically trying to combine code from two examples given in the DataTables documentation. The first example shows how to have multiple DataTables on one page, while the other allows you to show/hide details about each row.

I have applied the class “dataTable” to each of my dynamically generated tables, so the following code turns them all into DataTables (and disables sorting on the first column since that’s where the show/hide icon goes):

var oTable = $('.dataTable').dataTable({
    "aoColumnDefs" : [ {
        "bSortable" : false,
        "aTargets" : [ 0 ]
    } ],
    "aaSorting" : [ [ 1, 'asc' ] ]
})

Then I add an event listener to show/hide the additional row of details when the user clicks the image in the first column:

$('.dataTable tbody td img').live('click', function() {
    var nTr = $(this).parents('tr')[0];

    if (oTable.fnIsOpen(nTr)) {
        /* This row is already open - close it */
        this.src = "../examples_support/details_open.png";
        oTable.fnClose(nTr);
    } else {
        /* Open this row */
        this.src = "../examples_support/details_close.png";
        oTable.fnOpen(nTr, fnFormatDetails(), 'details');
    }
});

The problem is that this only works for the first DataTable on the page. When I click the show/hide icon in a row on any other table, the icon changes, but the details row does not appear. Further clicks on the same icon have no effect. Does anyone have any idea how to show/hide detail rows when using multiple DataTables on one page? I appreciate your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:58:55+00:00Added an answer on June 3, 2026 at 8:58 pm

    since you are defining

    var oTable = $('.dataTable').dataTable( \\YOURSTUFF)`;
    

    your variable oTable has all your dataTables as its value.

    The only thing you have to do is, to get the dataTable that contains your clicked element. You can achieve this by adding

    tbl = $(this).parent().parent().dataTable();
    

    to your click function and change all oTable calls to tbl.

    Have fun playing around with it 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I'm trying to combine two tables together into a new table. The first
I have the following snippets of code. Basically what I'm trying to do is
I'm trying to basically trying to separate a specific amount of text from the
I'm basically trying to get the target element from event.target and if not equal
I'm trying to combine some existing Qt code written in C++ with some code
trying to save a step and combine these two queries but not sure how
basically trying to remove corrupt, prematurely ending jpeg files from a collection. i figured
I'm basically trying to rewrite math.pow, I have the following obviously I'm not getting
I am basically trying to hide a DIV on the homepage but have it
Basically, I want to combine http://t16web.lanl.gov/Kawano/gnuplot/datafile2-e.html#7.4 and http://t16web.lanl.gov/Kawano/gnuplot/datafile2-e.html#7.2 . I'm trying to get a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.