How to set dynamically the Ajax URL of a dataTable?

后端 未结 3 1803
予麋鹿
予麋鹿 2020-12-09 12:04

I\'m using jQuery DataTables, my JavaScript code is shown below:

$(document).ready(function() {
   var tbl = $(\'#table_tabl\').DataTable({
      responsive:         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-09 12:35

    Datatable Version : 1.10.0-beta.1 Using fnDraw to Redraw the table.

    Sample code for using fndraw

    $(document).ready(function() {
      var oTable = $('#example').dataTable();
    
      // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
      oTable.fnDraw();
    } );
    

    Source

    $(document).ready(function() {
       var tbl = $('#table_tabl').DataTable({
          responsive: true,
          "oLanguage": {
             "sUrl": "fr_FR.txt",
          },
          "processing": true,
          "serverSide": true,
          "sAjaxSource": "server_processing_reservTables.php", // I want to add a parmeter to it dynamically when a select element is selected 
          "aoColumnDefs": [{
             "aTargets": [3],
             "mData": 3,
             "mRender": function(data, type, full) {
                return '
    '; } }], "aLengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "Tout"] ] }); $("#select_id").change(function () { var end = this.value; var NTypSource = 'server_processing_reservTables?type='+end+''; var oSettings = tbl.fnSettings(); oSettings.sAjaxSource = NTypSource; tbl.fnDraw(); }); });

提交回复
热议问题