Show hide details -> Ajax

Show hide details -> Ajax

jamesjw007jamesjw007 Posts: 35Questions: 0Answers: 0
edited June 2012 in General
I am trying to duplicate this functionality: http://datatables.net/release-datatables/examples/api/row_details.html

The only thing I have really changed is how fnFormatDetails(oTable, nTr) gets the data.

Here is a copy of the changes I made to the function itself. It correctly grabs the table from the page. But the problem is it is not throwing this data into the 'details' row. The row will open when I click the [+] image. But it is just an empty row.

[code]
/* Formating function for row details */
function fnFormatDetails(oTable, nTr) {
var aData = oTable.fnGetData(nTr);
var sOut = jQuery.ajax({
url: "ajax/order_history_orderlines.asp?orderid=" + aData[1],
context: document.body
});

return sOut;
}
[/code]

What order_history_orderlines.asp returns is the following table:

[code]
<!-- Teplate for orderlines found in rs Record Set -->




Quantity:


1


Description:


Combination Pack - All 3 Products





[/code]

Replies

  • snarf2larfsnarf2larf Posts: 64Questions: 0Answers: 0
    I do something similar in one of my tables. Although, I call the fnOpen directly from the function:

    [code]
    function openTable ( nTr ) {
    var aData = oTable.fnGetData( nTr );
    $.ajax({
    "url": "myurl/" + aData[0],
    timeout: 10000
    }).done(function( data ) {
    oTable.fnOpen( nTr, data, 'details' );
    }).fail(function () {
    oTable.fnOpen( nTr, 'Error', 'details' );
    });
    }
    [/code]

    I have my click event close the row if it is already open or run the openTable function. Works for me, hope this helps.
  • jamesjw007jamesjw007 Posts: 35Questions: 0Answers: 0
    YOU! Are the man. I was able to get this to work with your way of doing it. Thank you very much!
This discussion has been closed.