Some troubles with dt-responsible from Ajax Call Back

Some troubles with dt-responsible from Ajax Call Back

rhemanrheman Posts: 1Questions: 1Answers: 0
edited April 2019 in Free community support

Hi everyone,

  • I am trying to daw a responsive datatable from jquery Ajax Call Back.
  • When I daw the datatable from jquery Ajax Call Back, The datatable is drew but it's not responsive.
  • All required libraries are loaded.

My source code looks as follown:

****** HTML CODE ******

<table id="dataTableYear" class="table-responsive table-bordered table-striped table-hover dt-responsive">
</table>

***** JAVASCRIPT CODE *****

$(document).ready(function(){
    loadWaterBalance('day');
});

function loadWaterBalance(period){
$.ajax({
                url: 'loadwaterbalancejsonfile?t='+$.now(),
                cache: false,
                type: 'POST',
                data: {
                  'period': period
                },
                dataType: 'json',
                success: function (response) {
                  CallBack_loadWaterBalance(response.data, response.columns);
                },
                error: function (jqXhr, textStatus, errorMessage) { // error callback
                      alert('Error: ' + errorMessage);
                },
                      complete : function(jqXHR, textStatus){
               }
       });
}

function CallBack_loadWaterBalance(datatable_array, datatable_column){
var table = $("#dataTableYear").dataTable({
        "serverSide": false,
        "searching": true,
        "ordering": false,
        "info": false,
        "paging": false,
        data: datatable_array,
        columns: datatable_column
    });
}

Best regard,

Answers

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    Hi @rheman ,

    Either the table should have the class responsive, see here, or responsive should be set. If still no joy, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.