javascript - Is there a way to pull from multiple SQL tables for one DataTables table? -


i use datatables present data in reporting website created. working on creating report builder users can select multiple tables , columns tables custom report.

what want know whether there's way datatables. i'm able tables names , column names custom report, i've not been able figure out how send datatables. use server side processing , send ajax call using post datatable.

i know can program in sql query based on selected tables , columns, cannot seem figure out how have data sent datatables.

here how initialize datatables:

$(document).ready(function () {     // setup - add text input each footer cell     $('#datatable tfoot th').each(function ()           //creates search bar footer     {         var title = $(this).text();         $(this).html('<input type="text" placeholder="search ' + title + '" />');     });      var table = $('#datatable').datatable({         "lengthmenu": [[25, 50, 75, 100, 150, -1], [25, 50, 75, 100, 150, 'all']],         "dom": '<"top"bifpl<"clear">>rt<"bottom"ip<"clear">>',         "buttons": [{             extend: 'collection',             text: 'export',             buttons: ['export', { extend: 'csv',                 text: 'export csv',              //export csv file                 action: function (e, dt, node, config)                 {                     window.location.href = './serverside.php?exporttocsv=yes';                 }             }, 'csv', 'pdf', { extend: 'excel',                 text: 'export current page',            //export excel current page , highlight first row headers                 exportoptions: {                     modifier: {                         page: 'current'                     }                 },                 customize: function (xlsx)                 {                     var sheet = xlsx.xl.worksheets['sheet1.xml'];                     $('row:first c', sheet).attr('s', '7');                 }             }]         }         ],         "fixedheader": {                                //keeps header , footer visiable @ times             header: true,             footer: true         },         "select": true,                                 //sets ability select rows         "processing": true,                             //shows "processing" when working         "serverside": true,                             //sends data server processing         "ajax": {                                       //where data sent , processed             "url": "./serverside.php",             "type": "post"         },         statesave: true,                                //saves current state of page         columndefs: [{ visible: false, targets: 0}],    //hides first column id column         initcomplete: function ()                       //sets search         {             var api = this.api();              // apply search             api.columns().every(function ()             {                 var = this;                  $('input', this.footer()).on('keyup change', function (e)                 {                     if (that.search() !== this.value & e.keycode == 13) //you have hit enter search start                     {                                                   .search(this.value)                           .draw();                     }                 });             });         }     }); });  $.fn.datatable.ext.buttons.export = {     classname: 'buttons-alert',                         //adds "export excel" button     id: 'exportbutton',     text: "export excel",     action: function (e, dt, node, config)     {         window.location.href = './serverside.php?exporttoexcel=yes';     } }; 

here can work: enter image description here

i'm not sure else need me this, if i'm missing let me know , i'll add it.

i need data selected tables , columns in 1 datatables table presented on website. in image above i'm showing i've gotten far getting column headers , using aliases tables. i'm working through filtersort.class.pph file (which ssp.class.php in datatables) see if can present table.

i figured out. still calling correct datatables functions, wasn't passing data functions. ended having update serverside.php file , filtersort.class.php file. ones of other reports use send data server screen. after trial , error, got work , didn't need change in code posted in question.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -