deferLoading

deferLoading

dpotamdpotam Posts: 5Questions: 2Answers: 1

Hello! Am i right understand that deferLoading help me at next case? I have table with 200K rows. When browser open search page with html form then table under this form content entire data from database. Can i not run initial request? Just need to run search and display after html button was pressed.

<script type="text/javascript" language="javascript" >
$(document).ready(function() {
        var dataTable = $('#grid').DataTable( {
                "processing": true,
                "serverSide": true,
                "deferLoading": 0,
                "ajax":{
                        "url" :"employee-grid-data.4.php", // json datasource
                        "type": "post",  // method  , by default get
                },
          } );
 } );
</script>

<button id="btn-reload" type="submit" class="ui left floated green button">Search</button>

<table id="grid" class="ui selectable compact small celled green table" cellspacing="0">
        <thead>
                <tr>
                        <th>column_1</th>
                        <th>column_2</th>
                        <th>column_3</th>
                        <th>column_4</th>
                        <th>column_5</th>
                        <th>column_6</th>
                        <th>column_7</th>
                </tr>
        </thead>
</table>

This question has an accepted answers - jump to answer

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    you are right in that the deferLoading can delay your first load, however, if you are returning all of your data without it, then you have not properly implemented severSide loading. You should never get back more than one page's worth of data.

    Is that the issue you are having?

  • dpotamdpotam Posts: 5Questions: 2Answers: 1
    edited June 2017

    Sorry, my english is to low. If i right understand my mistake that my serverside script do some initial request (select * from table) for get amount of rows in table (200000). This amount it use for displaying under grid like "Records 1 to 10 from 60 (filtered from 200000)".

  • dpotamdpotam Posts: 5Questions: 2Answers: 1
    edited June 2017

    What i have now. After submit form the table is empty. But if i click on "Page 2" link or change amount "Records per page" then table have data. Then click on "Page 1" link and table redrawing with data from first page. But why it not display data after submit form?

  • dpotamdpotam Posts: 5Questions: 2Answers: 1
    edited June 2017 Answer ✓

    Thx a lot for help! It help to solve trouble. Put sql request into

    if (!empty($_POST['form_field_post_name'])) {
    
    }
    

    and searching working fine for me now.

    In this case sql request will be run only if some post-header was received (submit button will send this header).

This discussion has been closed.