Defer render

Defer render

calacala Posts: 52Questions: 15Answers: 0

Hi!

Is it possible to defer render also when server processing is in use? In the example is always only with ajax that load data:

$(document).ready(function() {
    $('#example').DataTable( {
        "ajax": "data/arrays.txt",
        "deferRender": true
    } );
} );

Thank you!

Answers

  • calacala Posts: 52Questions: 15Answers: 0
  • allanallan Posts: 63,412Questions: 1Answers: 10,454 Site admin

    Deferred loading is slightly different from rendered rendering. Deferred rendering has no meaning when server-side processing since only the rows required for display will be created by definition.

    Allan

  • calacala Posts: 52Questions: 15Answers: 0
    edited October 2015

    So I must only "preload" the first 10 rows in the html and set "deferLoading" to the max num of row in my table?

    Another thing: this affects the performance of the Editor? I've tried with 1000 rows and is ok, 5000 is very slow, also the loading of new/edit window.

    Thank you!

  • allanallan Posts: 63,412Questions: 1Answers: 10,454 Site admin

    If you want to use the deferred loading feature then, yes, that is the correct way to do it.

    Another thing: this affects the performance of the Editor?

    Server-side processing should be very fast. If it isn't for you, can you link to the page showing the issue please.

    Allan

  • calacala Posts: 52Questions: 15Answers: 0
    edited October 2015

    Is it possible to create the "preview" html with child rows?

    the site is on a private server, I cannot link you the page.

    If needed, I can give you the debugger link: http://debug.datatables.net/onemeh

  • calacala Posts: 52Questions: 15Answers: 0

    I see now that in the debugger that the processing is client side... maybe that is the problem.

    Only if I set

    "serverside"=true
    

    instead of

    "bserverside"=true
    

    the processing become server side, but in this case, no data is shown in the table...

  • allanallan Posts: 63,412Questions: 1Answers: 10,454 Site admin

    Try serverSide (note that capitalisation!).

    Allan

  • calacala Posts: 52Questions: 15Answers: 0

    Yes... I use it capitalized. I wrote the message in hurry yesterday.

    Could you explain me the difference between putting the b or not?

    However this morning I've reloaded the page and yes, data are loaded with a little delay, the pager is shown, but all the 1000 row are shown, instead of 10.

  • allanallan Posts: 63,412Questions: 1Answers: 10,454 Site admin

    Could you explain me the difference between putting the b or not?

    The bServerSide option is legacy - that is the format that was used prior to DataTables 1.10. v1.10 introduced camelCase option names, which are used in the documentation - e.g. serverSide. Both will work in 1.10.

    but all the 1000 row are shown

    Sounds like your server-side script is returning too many rows in that case. It should only return the number that DataTables requests. Is your LIMIT being correctly applied?

    Allan

  • calacala Posts: 52Questions: 15Answers: 0
    edited October 2015

    Both will work in 1.10.

    Great... but... why do they have 2 different behavior? I have to correct the behavior when I set severSide= true, because filtering, ordering nor paginating is working...

    Is your LIMIT being correctly applied?

    How can I set it?

    however: this is my js conf file (if can help):

    $(document).ready(function() {
        var table=$('#diego_table').DataTable( {
            select: true,
            //"paging": true, //DEFAULT TRUE
        processing: true,
        responsive: true,
        order: [[ 1, "desc" ]],
            //"info": true, //DEFAULT TRUE
            //"filter": true, //inserisce un search form (filtra i risultati) DEFAULT TRUE        
            
            serverSide: true,
    
            "ajax": "../server_processing_editor_3tab.php",
            //"deferLoading": 999,
            columns: [
                        " many columns definitions"
            ],
            dom: 'Blfrtip',
                buttons: [
                { 
                extend: 'create', 
                editor: editor,
                formTitle: function ( ) {
                    
                    // Get the data for the row and use a property from it in the
                    // form title
                    max_protocollo++;
                    var stringa= 'Creazione protocollo n° '+ (max_protocollo);
    
                    addOrRemove = true;
                    flag=false;
                        if ($( ".mod-button" ).hasClass( 'filtered' )){
                            $( ".mod-button" ).removeClass( 'filtered' );
                        }
                    return stringa;
                } },
                //{ extend: "remove",   editor: editor },
                {
                extend: 'edit',
                name:'edit',
                editor: editor,
                formTitle: function ( editor, dt ) {
                    // Get the data for the row and use a property from it in the
                    // form title
                    var rowData = dt.row({selected:true}).data();
                    //console.log(rowData);
                    flag=false;
                    addOrRemove = true;
                    if ($( ".mod-button" ).hasClass( 'filtered' )){
                        $( ".mod-button" ).removeClass( 'filtered' );
                    }
                    return 'Editing data for protocollo n° '+rowData.adati.protocollo;
                }},
                {
                    text: 'Per Mod',
                    className: 'mod-button'
                }
            ],
            "scrollX": true
        } );
    )};
    

    Thank you for the help!

  • allanallan Posts: 63,412Questions: 1Answers: 10,454 Site admin

    Great... but... why do they have 2 different behavior?

    So people who were using the 1.9 list of options can upgrade to 1.10 without everything breaking.

    How can I set it?

    It would be applied in whatever server_processing_editor_3tab.php is.

    Allan

This discussion has been closed.