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 8332297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:40:52+00:00 2026-06-09T02:40:52+00:00

I have a datatable that I am attempting to put drill-downs into based on

  • 0

I have a datatable that I am attempting to put drill-downs into based on the output of a php file, but I am having a few issues I can’t seem to figure out. I am using http://datatables.net/blog/Drill-down_rows as a guide. So far this is my code:

Javascript:

<script type="text/javascript">
    $("tr").live("click", function(){
        var nTr = this;
        var i = $.inArray(nTr, anOpen);
        //oTable = my datatable 
        var oData = oTable.fnGetData(nTr);
        if(i === -1) {
            $(this).addClass('row_selected');
            //THIS IS WHERE I AM GETTING A LITTLE LOST
            //I WANT THE VALUE OF response.details TO BE STORED IN nDetailsRow
            //oData.url is a mDataProp stored in the datatable row that contains the PHP link (this works okay)
            var nDetailsRow = $.get(oData.url, function(response) {
                //I don't really understand exactly what this is doing... but response.details is what I want to display from PHP
                oTable.fnOpen(nTr, response.details, 'details');
                });
            //THIS LINE DOES NOT WORK CORRECTLY BECAUSE nDetailsRow IS NOT WHAT I WANT IT TO BE 
            $('div.innerDetails', nDetailsRow).slideDown();
            anOpen.push(nTr);

        else {
        ...
        }
    }
</script>

PHP:

<?PHP
    $tableOut = '<div class="innerDetails">
                    <table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">
                        <tr><td>Test Cell:</td><td>This is a test</td></tr>
                    </table>
                </div>';

    $data = array();
    $data['details'] = $tableOut;

    echo json_encode($data);
?>

I feel like I am almost there, but I don’t quite understand the ajax $.get and am not sure if I am actually getting the JSON correctly from the PHP file. I also don’t quite understand how to store that JSON in the active jquery code. Any ideas on how to accomplish these tasks and how to get my drill-down to display the PHP JSON data response.details?

  • 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-09T02:40:54+00:00Added an answer on June 9, 2026 at 2:40 am

    I figured it out almost immediately after posting, I needed to use $.getJSON and include the last two lines inside that function. I am now using the following code which appears to work correctly:

    <script type="text/javascript">
        $(document).on("click", "tr", function(){
            var nTr = this;
            var i = $.inArray(nTr, anOpen);
            //oTable = my datatable & oData.url is the mDataProp link to the PHP page
            var oData = oTable.fnGetData(nTr);
            if(i === -1) {
                $(this).addClass('row_selected');           
                $.get(oData.url, function(response) {
                    oTable.fnOpen(nTr, response.details, 'details');
                    $('div.innerDetails', response.details).slideDown();
                    anOpen.push(nTr);
                    });     
    
            else {
            ...
            }
        }
    </script>
    

    Edit: Added/changed code from suggestions

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

Sidebar

Related Questions

I have a DataTable that I am attempting to upload, but I run into
I have created a datatable and trying to insert that datatable through SqlBulkCopy but
I have a datatable that has a date column, but I am stumped as
I have a DataTable that's had people wire into it's different column changed events,
I have a datatable that gets modified by having the html stripped out. During
I have a datatable that stores location values as such: CTY_CD, STATE_CD, COUNTRY_CD and
I have a DataTable that I manually created and loaded with data using C#.
I have a datatable that contains rows of transaction data for multiple users. Each
I have a datatable that I add to the chart in foreach loop as
I have a datatable that uses the cell editor function. In each row, I

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.