DataTable rows repeating/executing twice ?

DataTable rows repeating/executing twice ?

rahul.hendawerahul.hendawe Posts: 1Questions: 1Answers: 0
edited February 2017 in Free community support

Hello,

I have used below code to populate DataTable and it seems like the rows are repeating twice. How should I avoid this behavior?

 $('.datatable').DataTable({
        "fnDrawCallback": function( oSettings ) {
            alert( 'DataTables has redrawn the table' );
        },
        "language": {
            "processing": "<div class='overlay custom-loader-background'><i class='fa fa-cog fa-spin custom-loader-color'></i></div>"
        },
        "processing": true,
        "serverSide": true,
        "ajax": ({
            "url": contextRoot + "api/APIDirectory/GetDirectoryInfo",
                 "type": "POST",
                 "dataType": "JSON",
                 "data": {
                     "reqPath": reqPath
                 }
            }),
             "columnDefs": [{
                 "targets": 0,
                 "data": "fileName",
                 "render": function(data, type, row, meta) {
                     var path = window.location.pathname;
                     var path_array = path.split('/');
                     alert('PathArray_1' + path_array);
                     var fldName;        

                     if (path.endsWith("/")) {
                         fldName = path_array[path_array.length - 2];
                         alert('fld1:If In ' + fldName);
                     }
                     else {
                         fldName = path_array[path_array.length - 1];
                         alert('fld1:Else In ' + fldName);
                     }
                     var chkflName = data.split(".");

                     if (chkflName.length >= 2) {
                         if (chkflName[1] == "log")
                             return ' <i class="fa fa-file-text-o"></i> <a href="' + fldName + '/' + data + '" class="filelink" target="_blank">' + data + '</a>';
                         else if (chkflName[1] == "zip")
                             return ' <i class="fa fa-file-archive-o"></i> <a href="' + fldName + '/' + data + '" class="filelink" target="_blank">' + data + '</a>';
                         else if (chkflName[1] == "xml")
                             return ' <i class="fa fa-file-code-o"></i> <a href="' + fldName + '/' + data + '" class="filelink" target="_blank">' + data + '</a>';
                         else
                             return ' <i class="fa fa-file-o"></i> <a href="' + fldName + '/' + data + '" class="filelink" target="_blank">' + data + '</a>';
                     } else
                         return '<i class="fa fa-folder-o"></i> <a href="' + fldName + '/' + data + '/" class="folderlink">' + data + '</a>';
                 }
             }],
             "columns": [{
                 data: 'fileName',
                 title: "File"
             }, {
                 data: "fileSize",
                 title: "Size"
             }, {
                 data: "fileModified",
                 title: "Last Modifed"
             }],

             "sPaginationType": "full_numbers",
             "pageLength": 50,
             "order": [
                 [2, "desc"]
             ],
             "dom": "fltp",
             "aLengthMenu": [10, 25, 50, 100, 250, 500],
             });
This discussion has been closed.