Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery DataTables load large data

Tags:

jquery

php

How to load large data on databases into jquery datatables?

        $(document).ready(function(){
            $('#datatables').dataTable({
                "sPaginationType":"full_numbers",
                 "aaSorting": [[0, 'asc'], [1, 'desc']],
                 "sScrollY": "200px",
                "bJQueryUI":true
            });
        })

total data on xnod_kode table > 10000 records ???

                <?php

                $result = mysql_query("SELECT * FROM xnod_kode limit 10");
                $no = 1;
                while ($row = mysql_fetch_array($result)) {
                    ?>
                    <tr>
                        <td><?php echo $no; ?></td>
                        <td><?php echo $row['kodepos']?></td>
                        <td><?php echo $row['kelurahan']?></td>
                        <td><?php echo $row['kecamatan']?></td>
                    </tr>
                    <?php
                    $no++;
                }
                ?>
like image 762
Ega Gilang Ramadhan Avatar asked Sep 03 '13 19:09

Ega Gilang Ramadhan


1 Answers

In general, DataTables handles very large amounts of data best by paginating and fetching data via AJAX: http://datatables.net/examples/data_sources.

If your data varies, and >100,000 records is more of an outlier condition, you may consider using the DataTables scroller plugin: http://datatables.net/extras/scroller/. This creates a far superior user experience and can handle tens of thousands of rows under the right conditions. For optimal performance you'd probably want to remove your default sort from the script and place it in your PHP.

like image 74
cage rattler Avatar answered Sep 21 '22 18:09

cage rattler