DataTables with database
DataTables with database
Athirah94
Posts: 4Questions: 1Answers: 0
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
This discussion has been closed.
Answers
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
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 :/
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
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.
http://datatables.net/examples/server_side/object_data.html
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
Sorry. I just specify sql queries. Thanks for ur help btw.