Datatables Still Reloads and Draws After Reorder Although Set to False

Datatables Still Reloads and Draws After Reorder Although Set to False

anthony89anthony89 Posts: 26Questions: 8Answers: 0

I have set datatables to update: "false" but it stills performs an update and redraw. What am I doing wrong?

    var oQueueTable = $('#queue_table').DataTable( {
        paging: false,
        info: false,
        searching: false,
        rowReorder: {
            dataSrc: "sortID",
            update: "false"
        },
        processing: true,
        serverSide: true,
        ajax: root + "resources/php/data_handler.php",
        // use createdrow to add record id field to the tr id
        "createdRow": function( row, data, dataIndex ) {
            $(row).attr('id', data.id);
        },
        "drawCallback": function( settings ) {
            calc_eta();
        },

Later, I set the reorder function code:

    oQueueTable.on( 'row-reorder', function ( e, details, edit ) {
 
        var tmp_arr = [];
        var blnUpdate = true;
        for ( var i=0, ien=details.length ; i<ien ; i++ ) {
            var rowData = oQueueTable.row(details[i].node ).data();
            var rowID = parseInt(rowData.id);
            var sortID = parseInt(details[i].newData);
            if (rowID > 0 && sortID > 0){
                if (tmp_arr[i] === undefined) {
                    tmp_arr[i] = {rowID: rowID};
                } else {
                    tmp_arr[i].rowID = rowID;
                }
                if (tmp_arr[i] === undefined) {
                    tmp_arr[i] = {sortID: sortID};
                } else {
                    tmp_arr[i].sortID = sortID;
                }
            } else {
                blnUpdate = false;
            }
        }

        if (blnUpdate) {
            $.ajax({
                type: "POST",
                url: root + "resources/php/update_queuelist_sort.php",
                // The key needs to match your method's input parameter (case-sensitive).
                data: JSON.stringify({data:tmp_arr}),
                contentType: 'application/json',
                success: function(data){
                    console.log(data);
                },
                failure: function(errMsg) {
                    console.log("FBCRADIOCAST.JS row-reorder function: " + errMsg);
                }
            });            
        }
        
    });

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,309Questions: 26Answers: 4,947
    Answer ✓

    Looks like the rowReorder.update should be a boolean not a string. Change line 7 like this update: false .

    Kevin

  • anthony89anthony89 Posts: 26Questions: 8Answers: 0

    Thanks. That goes to show one's need to take a break from staring too long at code as that was too obvious.

    Anthony

This discussion has been closed.