Reload Table

Reload Table

starodubstarodub Posts: 6Questions: 2Answers: 0
edited December 2017 in Free community support

Hi, i need u help again
i need reload my table after click on btn #refresh, but this not working(

var table;
function main_table() {
  $(document).ready(function () {  
        table = $('#example').DataTable({
            ajax: {
                url: '/project/all_items/',
                dataSrc: ''

            },
            "sScrollY": "90vh", 
            "bPaginate": true,
            "aoColumns": [
                ...
            ],


        });
}

function refresh() {
    $('#refresh').click( function() {
        table.ajax.reload();
}

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,117Questions: 26Answers: 4,916
    Answer ✓

    My guess is that the refresh() function is not being executed. I would just put this code in the $(document).ready() function under the DT init code:

        $('#refresh').click( function() {
            table.ajax.reload();
    

    Kevin

  • starodubstarodub Posts: 6Questions: 2Answers: 0

    thanks, @kthorngren =)
    yep, i know it's working, but i need outside document ready (it's important)

    I found a solution
    $('#example').DataTable().ajax.reload();

    thanks it works)

This discussion has been closed.