each page same data is showing and pagination and search is not working

each page same data is showing and pagination and search is not working

SandeepMuralaSandeepMurala Posts: 48Questions: 13Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Answers

  • SandeepMuralaSandeepMurala Posts: 48Questions: 13Answers: 0

    I am using mongodb,I am pulling around 5k or 10k data from mongodb database.
    if I use normal datatable concept it is taking longer time to load data,

    so to reduce that I have done server side code like shown in below .
    get_data.php file result shown in below .

     {"iTotalRecords":20,"iTotalDisplayRecords":10,"data":[],"aaData":[["sandeep000","name","phone","21212","PLSQL DEVLOPER","","","","","","",""],["namess","122121","1234567","sa","DEVLOPER","","","","","","",""],["name12","lastname","phone","name","DEVLOPER","","","","","","",""],["lastname","skill","phone","name","PLSQL","","","","","","",""],["lastname","","phone","name","skill","","","","","","",""],["name","","Test","Test","Test","","","","","","",""]]}
    
    

    Here total records count I have given iTotalDisplayRecords:10 .total 10 pages are showing in pagination but each page has some date and each page contains 20
    records , for testing I have given 20 ,If I pull 4k records each page 4k records is showing and when go next page same data is reflecting .

    In display.php file code is like this .

     $(document).ready(function(){
            $('#datatable_emp_details').dataTable({
                "sServerMethod": "POST", 
                "bProcessing": true,
                "bServerSide": true,
                "paging": true,
                "pageLength": 10,
                "sAjaxSource": "get_data.php",
                 //"columnDefs": [{
        //"defaultContent": "-",
        //"targets": "_all"
      //}]
            });
          
        });
    
    
    
                    <table class="table m-0 tableFixHead" name="datatable_emp_details" id="datatable_emp_details"  cellspacing="0"> <!-- tableFixHead-->
                  <thead style = "background-color:#59BBE3 !important;color:#ffff;">
                      <tr style = "font-size:15px;">
                        <!--  <th style = "width:20.5833px !important;">#</th> -->
                        <th style = "width:25px;display:none">create date</th>
                          <th style = "width:25px;">Name</th>
                          <th style = "width:25px">column2</th>
                          <th style = "width:25px">column3</th>
                          <th style = "width:25px">column4</th>
                          <th style = "width:25px">column5</th>
                          <th style = "width:25px">column6</th>
                          <th style = "width:25px">column7</th>
                          <th style = "width:25px">column8</th>
                          <th style = "width:25px">column9</th>                   
                          <th style = "width:25px">column10 </th>
                          <th style = "width:25px">column11</th>
                          <th style = "width:25px">column12</th>
                          <th style = "width:25px">Phone Number</th>
                          <th style = "width:57px">Action</th>
                      <!--    <th>Action</th> -->
                      </tr>
                  </thead>           
                  <tbody>
                                       
                  </tbody>
              </table>
    
    
    

    Here data is displaying and not taking so much of time but pagenation is not working and search is also not working (I need to do individual column search also on the same table )

    please help on it .

    Thanks
    Sandeep

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    It looks like your server-side script isn't complying with the expected protocol. The protocol is discussed here. Also see examples here. If you download the DataTables repo, there are examples of the server-side scripts in /examples/server_side/scripts,

    Cheers,

    Colin

  • SandeepMuralaSandeepMurala Posts: 48Questions: 13Answers: 0

    @colin ,Thanks for response .

    Could you please explain little more ,I did not get you.

    And I am using Mongodb datatable ,When I was using Mysql I have done properly , but now I am using Mongodb so Please help on it .

    Or explain Any anther way we can do this server side script using Mongodb .

    Thanks
    Sandeep

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Check the links I posted above, they'll explain what you need to do. Your server-side script needs to respond in a certain way to the client's requests - those responses are discussed in the links.

    Colin

Sign In or Register to comment.