Show hide details -> Ajax
Show hide details -> Ajax
jamesjw007
Posts: 35Questions: 0Answers: 0
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]
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]
This discussion has been closed.
Replies
[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.