Different Tables From Different DB Tables On A Single Page
Different Tables From Different DB Tables On A Single Page
Hello guys, please forgive me if this question has been asked already in other form. I looked through the questions but couldnt find a similar one.
I want to build two different tables on a single page but each of these two tables will be populated with data coming from separate DB tables. I have created separate php files to handle data into and out of each tablle and i have two different tables on the HTML file each with a uniqiue id property. My problem now is with the js file. i cant just get my head around it.
This is what i have on the js file:
************************************************CODE BEGINS************************************************************
(function($){
$(document).ready(function() {
var editor = new $.fn.dataTable.Editor( {
ajax: 'assets/datatable_assets/php/table.nestor_exchangerates.php',
table: '#nestor_exchangerates',
fields: [
{
"label": "Currency:",
"name": "exchangerate_currency"
},
{
"label": "Date:",
"name": "exchangerate_date",
"type": "datetime",
"format": "YYYY-MM-DD HH:mm:ss"
},
{
"label": "Amount:",
"name": "exchangerate_amount"
}
]
} );
var table = $('#nestor_exchangerates').DataTable( {
dom: 'Bfrtip',
ajax: 'assets/datatable_assets/php/table.nestor_exchangerates.php',
columns: [
{
"data": "exchangerate_currency"
},
{
"data": "exchangerate_date"
},
{
"data": "exchangerate_amount"
}
],
select: true,
lengthChange: false,
buttons: [
{ extend: 'create', editor: editor },
{ extend: 'edit', editor: editor },
{ extend: 'remove', editor: editor }
]
} );
} );
}(jQuery));
******************************************************* END CODE**************************************************************
but it doesnt work. Please help.
Thank you.
This question has an accepted answers - jump to answer
Answers
Here is an example of two Datatables:
https://datatables.net/examples/basic_init/multiple_tables.html
You can create you second set of Datatables and Editor with different variables:
Use something different for the second set and make sure to use the correct variables for the buttons, etc:
Does this help answer your questions?
Kevin
thank you very much @kthorngren