Loading too high...

Loading too high...

lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

Hello, when my datables is working with 100 rows (in the sql table) it works fine, but when it works with a 1000+ rows database... it's so slowwwwww. Like 5 seconds to load the table. I think the table load EVERY rows in once. It is possible to fix this ?

«1

Replies

  • sphccronsphccron Posts: 2Questions: 0Answers: 0

    I am having the same problem as I have moved to IE11. IE 10 has no problem. Have restricted query to 1000 rows but still takes a lot longer than in IE10. I think the problem may be with the latest updates to IE11.

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    Well I'm using google chrome.. :/

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    edited August 2014

    Heh - does that constitute a suggestion that you should upgrade Chrome to IE11? ;-)

    @lifedaniel - are you Ajax loading the data and have you enabled deferred rendering? See the FAQs.

    Allan

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    How can I use deferred rendering?

    Well I can't move from Chrome to IE.. too difficult :-P

    Thank you

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    Said Nothing ! I found it thank you very much Allan!

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    Well I've added

    "ajax": "php/table.datatabletest.php",
    "deferRender": true,

    in my javascript.

    Still take ages at the first loading. :/

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    up

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    Can you link to the page so I can take a look please.

    Allan

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    I work with wamp so kinda hard for me to give a link...

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    I'd suggest using the built in profiler in Chrome in that case to determine what is taking the time. I can't really helot o much without a link though.

    Allan

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    Thank you, here is the link

    http://votreserveur.com/test/mods/mod_clients/

    I hope you can help me with that

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    up to not lose the post

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    Thanks for the link - seems to load very quickly in Chrome for me. By far the biggest time delay is the download of the data which takes 0.5s. The table is rendered a fiction of a second after that.

    Allan

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    Thank you for your answer, the problem is I have only 3k rows (empty ones), but my real table got like 30k rows. 0.5 sec to load 10 rows per 10 rows is very high.. I don't know if you understand me

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    I would suggest using server-side processing in that case, as per the FAQ I linked to before.

    See also the manual's data gather page.

    Allan

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    when I use server side, look what happen : http://votreserveur.com/test/mods/mod_clients/

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    In which case you haven't implemented server-side processing, as documented in the manual. It looks like the entire data set is being returned.

    Allan

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    got "serverSide": true,
    "draw" : 1,
    "recordsFiltered": 10,
    "ajax": "php/table.datatabletest.php",

    as parameters

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    edited August 2014

    The link to the manual page shows the simplest serverside initialisation like so:
    $('#example').DataTable( { serverSide: true, ajax: '/data-source' } );

    Start simple and work up.

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    /data-source correspond to what? Cause I use "ajax": "php/table.datatabletest.php" atm

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    "data-source" means your data source.

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    maybe, but I'ts a file? Directory? It's what? I use ajax so : "ajax": "php/table.datatabletest.php" that replace the datasource.

    Still not working btw it load the 3k rows in the same file

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    You are retrieving the data so your "data source" must be correct.
    However, the example I posted does not include "draw" or "recordsFiltered". Why are you not using the example exactly?

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    Server-side processing is not simply a case of adding serverSide: true to the initialisation. You need to have a script that will actually perform the processing.

    That makes that the script you are ajax loading data from (table.datatablestest.php on your page) must implement the server-side processing protocol that is described int he manual, and that I have linked to before: http://datatables.net/manual/server-side .

    There is an example server-side processing PHP script included in the DataTables package and Editor supports it out of the box.

    Allan

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    I have exactly the same code as the example.. but nothing working for mine it loads all the data of the database in the same window

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    Well it seems I got an errror when I add :
    "type": "POST"

    here is the error : DataTables warning : table id=datatabletest - Unknown field : index 0

    What does it means? And why can't I add type post?

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    Not sure - would need to be able to see it. It is still going GET for me.

    What does it means?

    It is defined int he tech note that error links to: http://datatables.net/manual/tech-notes/4

    Allan

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0
    edited August 2014

    Javascript :

     $('#datatabletest').dataTable( {        
              "dom": "Tfrtip", 
              "ajax": {
                  "url": "php/table.datatabletest.php", 
                  "type": "POST"
                                             
              },
             
              "serverSide": true,
              
              "columns": [ ... ]
    ...
    

    PHP :

    <?php
    
    /*
     * Editor server script for DB table datatabletest
     * Automatically generated by http://editor.datatables.net/generator
     */
    
    // DataTables PHP library
    include( "lib/DataTables.php" );
    
    // Alias Editor classes so they are easy to use
    use
        DataTables\Editor,
        DataTables\Editor\Field,
        DataTables\Editor\Format,
        DataTables\Editor\Join,
        DataTables\Editor\Validate;
    
    
    // Build our Editor instance and process the data coming from _POST
    Editor::inst( $db, 'table' )
        ->fields(
            Field::inst( 'id' ),            
            Field::inst( 'nom' ),
            Field::inst( 'adresse' ),
            Field::inst( 'cp' )->validator( 'Validate::numeric' ),
            Field::inst( 'ville' ),
            Field::inst( 'pays' ),
            Field::inst( 'tel' ),
            Field::inst( 'fax' ),
            Field::inst( 'gsm' ),
            Field::inst( 'email' )->validator( 'Validate::email' ),
            Field::inst( 'tva' ),
            Field::inst( 'ctva' )   
        )
        
        ->process( $_POST ) 
        ->json();
    
  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    here you have my code

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    Thanks. However, the example you linked to is still using GET. Can you update it to use POST so I can see why POST is not working.

    Allan

This discussion has been closed.