alfajango / jquery-dynatable

A more-fun, semantic, alternative to datatables
http://www.dynatable.com
Other
2.78k stars 363 forks source link

How can I refresh the table and also update it #273

Open ukserversltd opened 7 years ago

ukserversltd commented 7 years ago

Hi guys,

Little new to JS so on a little bit of a struggle, I pull in a feed from my server which is working and the dynatable works however the issue i am facing i have a delete button to delete images using POST which deletes from the database and updates the json file but i need it to refresh the table as well but not sure how.

This is as far as i have got

$(function () {
    'use strict';

    //global
    var current_file_index = 0;

    // Initialize the jQuery File Upload widget:
    $('#fileupload').fileupload({
        // Uncomment the following to send cross-domain cookies:
        //xhrFields: {withCredentials: true},
        url: 'server/php/',
        prependFiles:true
    }).on('fileuploadsubmit', function (e, data) {
        //data.formData = {date: data.files[0].date};
        data.formData = data.context.find(':input').serializeArray();
    });

    // Load existing files:
    $('#fileupload').addClass('fileupload-processing');

    $.ajax({
        // Uncomment the following to send cross-domain cookies:
        //xhrFields: {withCredentials: true},
        async: false,
        url: $('#fileupload').fileupload('option', 'url'),
        dataType: 'json',
        context: $('#fileupload')[0],
        complete: function(result){
            //console.log('test');
        }
    }).always(function () {
        $(this).removeClass('fileupload-processing');
    }).done(function (result) {
        $(this).fileupload('option', 'done').call(this, $.Event('done'), {result: result});
        var dynatable = $('.table-striped').dynatable({
            dataset: {
                files: result,
                ajaxData: {
                    sorts: { 'date': -1 }
                }
            }
        }).data('dynatable');

        dynatable.process();
    });

});
infomastercode commented 3 years ago

https://stackoverflow.com/questions/24533976/reload-dynatable-data