Data Loading

Data Loading

sharcysharcy Posts: 16Questions: 4Answers: 0

How do I implement DataTables that uses infinite scrolling (or scroller) where all the data is NOT loaded when the table is initialized using DOM data?I have tried all the tips and documentation from the site on using scroller but still all my data if loaded upfront before scroller takes effect but it is really lagging and loads forever.I have 15000 records client side processing.
This is how currently my page looks like: http://debug.datatables.net/ikoxes and it does not show the scroller and also takes alot of time to load.Is there a way to limit the initial data being loaded into the table?

Answers

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    At the very least you need to Ajax load the data - examples. You are currently DOM loading the data which is just about the slowest option available. Ajax loading with deferred rendering will be fine for 15'000 rows.

    The next step beyond that is server-side processing.

    Allan

  • sharcysharcy Posts: 16Questions: 4Answers: 0

    I am currently implementing server-side processing but I get an error with code 7 that is http://datatables.net/tn/7 and the resulting explanation is not quite as per what I see in my debugger...how can I change the "throw" and is which code file do I do that?

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    What does your debugger show?

    Allan

  • sharcysharcy Posts: 16Questions: 4Answers: 0

    Hi,
    Thanks for the response...it gives me this error under Response tab: MySQL Error: 1064..

  • sharcysharcy Posts: 16Questions: 4Answers: 0

    Under Headers tab the status code is given as 500 Internal Server Error

  • sharcysharcy Posts: 16Questions: 4Answers: 0

    My debug code:http://debug.datatables.net/orodiq am trying to change my DT_bootstrap.js file so that it can reflect the new changes I have made but still gives out the same in the debug code...I wonder where the problem might be.I currently am using LIMIT 200 for my 15.000 records table because of slow loading and cannot also search through the records because of the error code 7

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

    I wonder where the problem might be

    Given "MySQL Error: 1064.." I would be checking my server-side processing script.

  • sharcysharcy Posts: 16Questions: 4Answers: 0

    Hi Tangering,
    I used this example for the server-side scripting: https://datatables.net/development/server-side/php_mysql

  • sharcysharcy Posts: 16Questions: 4Answers: 0

    I just changed the variables to fit my connection string...here is my output: http://debug.datatables.net/orodiq

  • sharcysharcy Posts: 16Questions: 4Answers: 0

    Where would I add this line: $.fn.dataTable.ext.errMode = 'throw'; in which js script for the error to go away?

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

    A MySQL error isn't going to "go away". You have to find out what your sql query looks like and fix it.

  • sharcysharcy Posts: 16Questions: 4Answers: 0

    Tangerine, am wondering what might be wrong as I have tried looking at the SQL query but the only suspect is "LIMIT" which I use because loading all my data into the table is taking ages...have you seen the code I use for server-side scripting?

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    The script you linked to is a legacy script. It should not be used with DataTables 1.10 unless you are using it in legacy mode (which it appears you are not - it looks like you are setting the Ajax options via the defaults in fact).

    I would suggest you use the ssp.class.php script from here and also checkout the examples in that directory for how to use it.

    Allan

  • sharcysharcy Posts: 16Questions: 4Answers: 0

    Hi Allan I'm even trying to run the demo from the examples folder but I get an error code 1.If I have a table called "members" from a db called "nochp" where would I place the table in the ssp.class.php file?

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    where would I place the table in the ssp.class.php file?

    You wouldn't - the ssp.class.php file is a library file that is used by some other scripts. Did you look at the other examples in the directory listing I linked to above? They show how the SSP class can be used and where you define the table and columns.

    Allan

  • sharcysharcy Posts: 16Questions: 4Answers: 0

    Yes Allan I looked at the other files anyway am currently working on it I will post my findings

  • sharcysharcy Posts: 16Questions: 4Answers: 0
    edited March 2015

    I am using the ssp.class.php file but I get an error code 4 and I have tried looking at the forums and also the manual where my problem lies is that I'm supposed to have buttons on my page which are dynamically added, so that is where I hit a snag...any idea on how to put buttons there?here is my current code without server-side processing:

    <tbody>
            <?php
            $query = $conn->query("select * from members LIMIT 1000");
            while ($row = $query->fetch()) {
            $id = $row['member_id'];
            $fn = $row['family_no'];
            ?>
            <tr>
            <td><?php echo $row['surname']; ?></td> 
            <td><?php echo $row['given_name']; ?></td> 
            <td><?php echo $row['middlename']; ?></td> 
            <td><?php echo $row['member_id']; ?></td> 
            <td class="empty" width="30"><input id="optionsCheckbox" class="uniform_on" name="selector[]" type="checkbox" value="<?php echo $id; ?>"></td>
            <td class="empty" width="160">
    
            <a data-placement="top" title="Click to View all Details" id="view<?php echo $id; ?>" href="view_member.php<?php echo '?id='.$id; ?>" class="btn btn-warning"><i class="icon-search icon-large"></i> View</a>
                <script type="text/javascript">
                $(document).ready(function(){
                    $('#view<?php echo $id; ?>').tooltip('show');
                    $('#view<?php echo $id; ?>').tooltip('hide');
                });
                </script>
            <a data-placement="top" title="Click to Add Dependents" id="view<?php echo $fn; ?>" href="Add_dependant.php<?php echo '?id='.$fn; ?>" class="btn btn-inverse"><i class="icon-plus-sign icon-large"></i> Add</a>
                <script type="text/javascript">
                $(document).ready(function(){
                    $('#view<?php echo $fn; ?>').tooltip('show');
                    $('#view<?php echo $fn; ?>').tooltip('hide');
                });
                </script>   
            </td>
            </tr>
        <?php } ?>    
        
            </tbody>
    

    How do I put these buttons that I have here on my table when using server-side scripting?

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    Use columns.render for dynamic content (i.e. that depends upon the data in the row) or columns.defaultContent for static content.

    Putting anything into a tbody loop when you have server-side processing enabled isn't going to do you any good at all since server-side processing will just remove it and replace it with the data retrieved from the server.

    Allan

This discussion has been closed.