Send fnGetData value as a query to database?

Send fnGetData value as a query to database?

Rawland_HustleRawland_Hustle Posts: 94Questions: 16Answers: 0
edited April 2014 in DataTables 1.10
My DataTables gets data from my mysql database. If my table consists of car brands, and I click a certain car brand, let's say "Ford", I want DataTables to ask my database for all the different models of "Ford" and display them in another table (with another set of column headers).

I think I'm supposed to use fnGetData for this, but I don't have a clue how to send the query and show the respons in a different table.

Could someone please tell me how I should get started?

Thanks!

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I'm not sure that the DataTables API is going to help a massive amount other than to get the data that was clicked upon. For example you might use:

    [code]
    $('#myTable').on( 'click', 'tbody td', function () {
    var cellData = table.fnGetData( this );

    createSubTable( cellData );
    } );
    [/code]

    The real work is in `createSubTable` which you'd need to write to make a call to the server, get the data you want and show it in the subtable. That's just standard Javascript to do that.

    Allan
This discussion has been closed.