How to reload full datatable, evenif row and col change numbers e data??

How to reload full datatable, evenif row and col change numbers e data??

GeasLuGeasLu Posts: 12Questions: 3Answers: 0

Link to test case: not possibile
Debugger code (debug.datatables.net): ??
Error messages shown: no error
Description of problem: My datatable load data from an ajax call and the number of columns depend from an interval of date. For example I have 2 params data_start-> 01/01/2021 and data_end->31/12/2021, so i will load 1 column for each month(12) if my paramas change, for example 01/06/2021->31/12/2021 I have to load only 6 column(1 for each month). But something wrong...first I try to use destroy() and empty(), but i lose graphic format and everycolumns is not allign with header, then i try clear().draw() but it's ok for data, but remain my header old and new in the same tabel!

How can i realoda fully datatabel?

Answers

  • GeasLuGeasLu Posts: 12Questions: 3Answers: 0

    Here is my code if ajax call success:


    dtb = $('#' + pIdDataTable).DataTable({ destroy: true, responsive: true, data : result['ValueCol'], dataSrc : "ValueCol", selectType : "row", "fnDrawCallback": function( oSettings ) { $(".sparkline" ).sparkline('html', {width: '70px', height: '30px'} ); }, language:{ "lengthMenu": "_MENU_ righe" }, //"scrollX": true, columns: result['HeaderCols'], dom: '"<\'row mb-3\'<\'col-sm-12 col-md-6 d-flex align-items-center justify-content-start\'f><\'col-sm-12 col-md-6 d-flex align-items-center justify-content-end\'B l>>" +\n' + ' "<\'row\'<\'col-sm-12\'tr>>" +\n' + ' "<\'row\'<\'col-sm-12 col-md-5\'i><\'col-sm-12 col-md-7\'p>>"', columnDefs:elnDefCol(result['IndexesColDef']) }); dtb.columns.adjust().draw(); break;
  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    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

Sign In or Register to comment.