How to alter the 5,000,000 scroller example?

How to alter the 5,000,000 scroller example?

DataTablesNewGuyDataTablesNewGuy Posts: 9Questions: 4Answers: 0
edited October 2014 in Free community support

All I am attempting to alter the 5,000,000 record scroller example to use an existing .txt file containing JSON.

Following example: http://datatables.net/release-datatables/extensions/Scroller/examples/server-side_processing.html
$(document).ready(function() {
$('#example').DataTable( {
serverSide: true,
ordering: false,
searching: false,
ajax: function ( data, callback, settings ) {
var out = [];

        for ( var i=data.start, ien=data.start+data.length ; i<ien ; i++ ) {
            out.push( [ i+'-1', i+'-2', i+'-3', i+'-4', i+'-5' ] );
        }

        setTimeout( function () {
            callback( {
                draw: data.draw,
                data: out,
                recordsTotal: 5000000,
                recordsFiltered: 5000000
            } );
        }, 50 );
    },
    dom: "rtiS",
    scrollY: 200,
    scroller: {
        loadingIndicator: true
    }
} );

} );

How can I alter the code to call a txt file which is in the format:

       [
     {
       "Host name":"212430319VM",
  "Software title":"Microsoft Visual C++ 2010 SP1 Redistributable x64 64"
         }, etc........
      ]

Answers

  • DataTablesNewGuyDataTablesNewGuy Posts: 9Questions: 4Answers: 0
    edited October 2014

    Anyone have an example whereby they used php or a json file?

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    serverSide: true,

    Is not going to be compatible with a static text file - unless you have some kind of proxy in the middle which implements server-side processing.

    If you have just a static text file, then you probably just want to use client-side processing and load the whole lot upfront.

    Allan

  • DataTablesNewGuyDataTablesNewGuy Posts: 9Questions: 4Answers: 0
    edited October 2014

    Allan,
    Whenever I load the data client-side I get the error "allocation size overflow". I receive this error when using the following code:

           $(document).ready(function () {
                  $('#example').DataTable({
             ajax: "../reports/software_report.txt",
             "sAjaxDataProp": "",
    
             "aoColumns": [
                { "mData": "Host name" },
                { "mData": "Software title" }],
             deferRender: true,
             dom: "frtiS",
             scrollY: 200,
             scrollCollapse: true
    
         });
     });
    

    I went away from server side processing because I was having trouble constructing my PHP file. I repeatedly receive a memory issue because the array grew too large. FYI, my datasource is a MS SQL server.

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    How big is software_report.txt?

    If more than 50k records, you'll need to implement server-side processing. Indeed, it sounds like you might need to regardless if the client-side is running out of memory.

    Try making the file smaller and see if it suddenly works. That would confirm if it is a memory issue.

    Allan

This discussion has been closed.