refresh datatable with data

refresh datatable with data

michaelindramichaelindra Posts: 2Questions: 1Answers: 0
edited October 2018 in Free community support

Hi everyone. I want to ask my problem

     $('.tanggal').datepicker({
            format: "yyyy-mm-dd",
            autoclose:true~~~~
        }).datepicker('setDate', 'today')
          .on('changeDate', function(e){
            tabel.ajax.reload();
          });

        tabel = $('#example').DataTable({
           "processing": true,
           "serverSide": true,
           language: {
                infoEmpty: "No records available - Got it?",
            },
           "ajax": {
               "url": "<?php echo base_url('absensi/datatables_ajax');?>",
               "type": "POST",
               data : {tanggal : $("input[name =tglibadah]").val()}
           },
           columnDefs: [{
                targets: 3,
                searchable: false,
                orderable: false,
                className: 'dt-body-center'

            }]
        });

when i change datepicker, a value date is change. but data on ajax is not change. can anyone see my mistake? thank you

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @michaelindra ,

    If you look at this example here, the custom variable is being added within the existing data set - I suspect yours is overwriting it. Try doing it the same way as in that example.

    If that doesn't help, we're happy to take a look, but it would help, as per the forum rules, if you could link to a running test case showing the issue so we can offer some help. 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

  • michaelindramichaelindra Posts: 2Questions: 1Answers: 0

    Hi Colin.
    Thank you for response my question
    i'm sorry if i fault a forum rule. Because this first time i ask :D

    Mmm i will explain my problem. I have datepicker and DataTables. If i change datepicker, my DataTables is changed too. The problem is datepicker change but DataTables no change. I'm confuse what's wrong with my code.

    But thank you for example.

    I'm sorry if i have bad language

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @michaelindra ,

    Yep, as I said, we're happy to take a look if you could link to a page or test case demonstrating the problem,

    Cheers,

    Colin

This discussion has been closed.