[DT 1.10] Refresh HTML table

[DT 1.10] Refresh HTML table

deliatordeliator Posts: 95Questions: 1Answers: 0

Hello,

Here is my example :

http://live.datatables.net/juxayame/3/

On button click i need to refresh the table content

Thanks

Replies

  • kthorngrenkthorngren Posts: 20,302Questions: 26Answers: 4,769

    On button click i need to refresh the table content

    What do you want to refresh the table with?

    Your example does really explain what you are wanting to do.

    Kevin

  • deliatordeliator Posts: 95Questions: 1Answers: 0

    The content of the table is the result of a query located in the same html page (language is coldfusion)

    I fi click one of the buttons it makes an ajax call to the file ajaxFilter.cfm with a parameter 'action' equal to On or Off, the page ajaxFilter.cfm is just the definition of a session variable depending of the passed parameter.
    For example in this test : session.age = 26, then the query is adapted.
    I just have to reload the table.

    Link adapted : http://live.datatables.net/juxayame/4/

  • kthorngrenkthorngren Posts: 20,302Questions: 26Answers: 4,769

    You want to update the Datatable with the data parameter in the done function, correct?

    If so then you probably will want to use clear() to clear the table then use rows.add() to add the data passed into the done function.

    Kevin

  • deliatordeliator Posts: 95Questions: 1Answers: 0
    edited May 2019

    Thanks Kevin, i changed the way i use the plugin. I'm using the server side option.
    So i just have to use :

    $('#data').DataTable().ajax.reload();

    Paging is working correctly, search is working too (display of info is changed) but i don't know why the table refresh is not working.

    I can't give you a live example because page is on the intranet :/

    here is the script :

    var oTable = $('#data').DataTable({
             dom:
                "<'row'<'col-sm-3'l><'col-sm-6 text-center'B><'col-sm-3'f>>" +
                "<'row'<'col-sm-12'tr>>" +
                "<'row'<'col-sm-5'i><'col-sm-7'p>>",        
            paging:   true,
            select: 'single',
            ordering: true,
            info:     true, 
            processing: true,
            serverSide: true,
            ajax: {
                url: 'theData.cfm',
                dataSrc: 'persons'
            },
            columns: [
                {'data': 'field1'},
                {'data': 'field2'},
                {'data': 'field3'},
                {'data': 'field4'}
            ],
            columnDefs: [
                { width: "40px", className: "text-center", "targets": [ 0 ] },
                { width: "80px", className: "text-left", "targets": [ 1 ] },
                { targets: [ 1, 2, 3 ], visible: true, searchable: true },
                { targets: [ 0 ], visible: false, searchable: false },
            ],
        },
    

    Marc

  • deliatordeliator Posts: 95Questions: 1Answers: 0

    Ok, i made a mistake in the data source :-)

    Resolved by myself, thanks for help.

    Regards,

    marc

This discussion has been closed.