phptreetable

how to reload or refresh data in treeTable in php


i have issue on use treeTable while reload data and after save and update data form

$(document).ready(function() {
    const datajson = <?php echo $data_json  ?>;
    $('#tablejson').treeTable({

        "data": datajson,
        "collapsed": true,
        "responsive": true,
        "lengthChange": true,
        "autoWidth": false,
        "fnDrawCallback": function() {
            $('[data-toggle="tooltip"]').tooltip();
        },
        "aLengthMenu": [
            [10, 50, 100, -1],
            [10, 50, 100, "All"]
        ],
        "iDisplayLength": 10,
        "columns": [{
                "data": "nama_module",
            },
            {
                "data": "controller",
            },
            {
                "data": "function",

            },
            {
                "data": "nm_group",

            },
            {
                "data": "label",

            },
            {
                "data": "btn"
            }
        ],
        "order": [],
    });

    $('#btn-reload').click(function() {
        $('#tablejson').dataTable().api().ajax.reload();
    });
});

i try to click button for reload tabel use $('#tablejson').dataTable().api().ajax.reload(); but not working, this is happen while i use treeTable, if i use datatable only its work for reload or refresh table.

does anyone have the same case with me ? thanks


Solution

  • finally, i found a solution in my case, i use code like this

     $('#btn-reload').click(function() {
            $('#tablejson').DataTable()
                .order([2, 'desc'])
                .draw();
        });
    

    thanks....