How do I fetch sql data inside row details.

How do I fetch sql data inside row details.

pixelwolfiepixelwolfie Posts: 2Questions: 0Answers: 0
edited December 2012 in General
Hi all, I currently have one single table that fetches from an sql database. However, I do not want all of the data to be seen at first glance, hence I used the row details function. So upon clicking the plus button, there would be a table showing the remaining data which is also taken from the same sql database for the particular row.

[code]
function fnFormatDetails ( oTable, nTr )
{
var aData = oTable.fnGetData( nTr );
var sOut = '';
sOut += 'Item IdItem DescriptionQuantityPrice';
sOut += '';
return sOut;
}
[/code]

The code above is a table I've inserted for the row details, but I'm not sure how to retrieve rows from the sql database based on the original table rows.

This is a pic of how it looks like:
http://i1303.photobucket.com/albums/ag150/pixelwolfie/rowdetails.png

Thanks,
Pixelwolfie

Replies

  • girishmrgirishmr Posts: 137Questions: 0Answers: 0
    edited December 2012
    Bind a click event for each row of the parent table. On click, get the row id ( assuming that it would be hidden and will be the first column - aData[0] ), fetch records for the selected row id from the database.

    Check http://www.datatables.net/blog/Drill-down_rows

    [code]
    $('#example td.control').live( 'click', function () {
    var nTr = this.parentNode;
    var i = $.inArray( nTr, anOpen );
    var aData = oTable.fnGetData( nTr );

    var rowId = aData[0];

    // other code
    });
    [/code]
This discussion has been closed.