SSP Class- Valid JSON returned but nothing drawn

SSP Class- Valid JSON returned but nothing drawn

ChrisFChrisF Posts: 15Questions: 7Answers: 0
edited June 2018 in Free community support

I started using serverside processing, I am using the provided SSP Class from the forums. When logging the response it seems like I am getting a valid JSON data (also tested). I have 1 test row but its not drawn.
{ "draw": 1, "recordsTotal": 1, "recordsFiltered": 1, "data": [ ["1", "qwe", "20", "qwe", "qwe", "20", "qwe", "qwe", "qwe", "qwe", "2"] ] }

What could be the issue?
The code for the datatable itself:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="../../dist/js/bootstrap.min.js"></script>
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>


<script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.flash.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.print.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.16/api/sum().js"></script>
<script src="vendor/jquery/jquery-1.11.2.min.js" type="text/javascript"></script>





<script type="text/javascript">


    $(document).ready(function () { var table= $('#usertable').DataTable({

        
        dom: 'Blfrtip',
        buttons: [
            { extend: 'excel', text: 'Export do excelu', className: 'excelbutton',
                exportOptions: {
                    columns: [0,1,2,3,4,5,6,7,8,9,10,11,12,13]
                }
            },
            { extend: 'pdf', text: 'Export do PDF', className: 'excelbutton',
                exportOptions: {
                    columns: [0,1,2,3,4,5,6,7,8,9,10,11,12,13]
                }
            }
        ],


        "ajax": "mysite/connecttovykresy.php",
        "processing": true,
        "serverSide": true,



        language: {
            search: "Hľadať:",
            info:"Zobrazujem _START_ do _END_ zo _TOTAL_ záznamov",
            lengthMenu:     "Zobraziť _MENU_ záznamov",
            infoEmpty:      "Zobrazujem 0 do 0 z 0 záznamov",
            infoFiltered:   "(filtrované z _MAX_ celkových záznamov)",
            zeroRecords:    "Neboli nájdené žiadne zodpovedajúce záznamy",
            paginate: {
                next:       "Ďaľšia",
                previous:   "Predchádzajúca",
            }
        }

    } );

        $('.dataTables_filter input').unbind().bind('keyup', function() {
            var searchTerm = this.value.toLowerCase(),
                regex = '\\b'+searchTerm ;
            table.rows().search(regex, true, false).draw();
        });



    } );



</script>

What am I missing here?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited June 2018 Answer ✓

    Hi @ChrisF ,

    I suspect it's because of a disparity in column numbers. Your JSON above has 11 columns, whereas your exportOptions are showing you have at least 14. It would be worth double checking to make sure there is the correct number in the HTML.

    Cheers,

    Colin

This discussion has been closed.