0

I'm new to Bootstrap Data Table and I'm trying to implement it in my .NET MVC web application. I have enabled pagination for the Data Table. So when my web page is loaded it will display only the first 10 records(other options are 25,50,All etc.) by default.

I'm intending to do the following :

  • Suppose I have a total of 1000 records in my DB.
  • So when my page is first loaded it should only fetch first 10 records(or first 25 if 25 records are selected and so on) instead of all 1000 records. This would to improve the performance.
  • The next 10 records should only be fetched when the user asks for next data to be displayed.

How can I get this done?

I found out about deferLoading and deferRender options but I'm not sure which one is suitable for my case. Are there any other options?

Mr.Human
  • 547
  • 2
  • 12
  • 30

2 Answers2

0

I am new to this too and just come across your question as I need to do the same thing. I have found this page on the datatables website.

https://datatables.net/examples/server_side/simple.html

$(document).ready(function() {
    $('#example').DataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": "scripts/server_processing.php"    
    } );    
} );
Gyrocode.com
  • 57,606
  • 14
  • 150
  • 185
Ian GM
  • 779
  • 3
  • 9
  • 18
  • I already had gone through this section you've mentioned. But I had a doubt about it because the data is being fetched from the AJAX file and not DB. As per the example I think they have manually fed the AJAX file. So this would not be an effective technique for large set of data – Mr.Human Nov 07 '16 at 11:34
  • Although there's no doubt that Server Side Processing could be a solution for our requirement ( or maybe deferLoading and deferRender). – Mr.Human Nov 07 '16 at 11:40
  • I think that I will need to use Fiddler to see what data is being posted to my controller when I get that far. From what I have seen so far this link gives me a good clue... http://stackoverflow.com/questions/3531438/jquery-datatables-server-side-processing-using-asp-net-webforms – Ian GM Nov 07 '16 at 12:41
  • And this one... http://stackoverflow.com/questions/3193930/using-jquery-datatable-for-server-side-processing-with-paging-filtering-and-sea – Ian GM Nov 07 '16 at 12:42
  • Thanks Ian. I went through the links which you provided. Found out this link as helpful : http://www.dotnetawesome.com/2015/11/jquery-datatable-server-side-pagination-sorting.html – Mr.Human Nov 08 '16 at 05:45
  • It implements server-side processing and just fulfills our requirement. – Mr.Human Nov 08 '16 at 05:46
0

I referred the following article and it fulfills my requirement : http://www.dotnetawesome.com/2015/11/jquery-datatable-server-side-pagination-sorting.html Features like server-side processing and on-demand loading of data are covered in this article.

Mr.Human
  • 547
  • 2
  • 12
  • 30