DataTables with database

DataTables with database

Athirah94Athirah94 Posts: 4Questions: 1Answers: 0
edited December 2014 in Free community support

Is there any example that uses datasource from the database for DataTables :
http://www.datatables.net/examples/api/row_details.html

If so, is there any links that u can give me? Since i'm just an amateur.

I know the data are on this lines :

$(document).ready(function() {
    var table = $('#example').DataTable( {
        "ajax": "../ajax/data/objects.txt",
        "columns": [
            {
                "className":      'details-control',
                "orderable":      false,
                "data":           null,
                "defaultContent": ''
            },
            { "data": "name" },
            { "data": "position" },
            { "data": "office" },
            { "data": "salary" }
        ],
        "order": [[1, 'asc']]
    } );

but how to change them to fetch the data from sql queries specifically? Since don't have any knowledge on ajax.

Thanks for your kind help

Answers

  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin

    I don't really understand what you are asking I'm afraid. Are you wondering how to create the JSON object that DataTables is reading? If so, I would suggest asking in a forum specific to the server-side language you are writing in, or StackOverflow for general questions.

    Allan

  • Athirah94Athirah94 Posts: 4Questions: 1Answers: 0

    Allan, what i meant is the data are from remote datasource. All of the given examples are in .txt file / ajax. But i want the data from remote datasource :/

  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin

    Some examples use PHP to create the JSON.

    I still don't really understand what you are looking for though - how the JSON is created is irrelevant to DataTables - it just needs a JSON feed from somewhere.

    Allan

  • Athirah94Athirah94 Posts: 4Questions: 1Answers: 0

    okay. In the code above, all of the data were retrieved from this line....

    /ajax/data/objects.txt

    But i want the data to be retrieved from the database.

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Some examples use PHP to create the JSON.

    http://datatables.net/examples/server_side/object_data.html

  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin
    edited December 2014

    As I said, where the JSON data comes from (be it .NET, a Python script, Node.JS, PHP, a text file, whatever) DataTables really doesn't care very much. It just needs JSON data to be displayed.

    You've not even told us what server platform you are using.

    Allan

  • Athirah94Athirah94 Posts: 4Questions: 1Answers: 0

    Sorry. I just specify sql queries. Thanks for ur help btw.

This discussion has been closed.