1

Created mvc 4 application.currently In that Application I'm loading thousands of records using client side pagination. this is how I do it

  1. Using select all Linq query I'm selecting all the recodes in that table
  2. Then using jquery tablesorter plugin its deviding all those records in to 10 by 10 chunks , showing those results page by page

here a picture of it

enter image description here

Since this is large set of data its taking too much time to load.There for I decided to do this using server side pagination.

but I have no idea to achieve this , could you suggest me a way to do this using jquery table sorter (without using jquery Data table)

This is controller class

 public ActionResult Index()
 {

       return View(db.table_name.ToList());

 }

This is how I used jquery table sorter plugin

<script type="text/javascript">
    $(function () {
        $("#table-hover")

            .tablesorter({

                widthFixed: true,
                serverSideSorting: false

            })

            .tablesorterPager({
                container: $("#pager"),
                size: $(".pagesize option:selected").val()
            });

    });
 </script>
kez
  • 2,273
  • 9
  • 64
  • 123
  • You can also do this using (stored) procedure. Simply add a page number to your controller and pass it to the model and procedure. Here are some good references for pagination in SQL Server: [A More Efficient Method for Paging Through Large Result Sets](http://www.4guysfromrolla.com/webtech/042606-1.shtml) and [Row Offset in SQL Server](https://stackoverflow.com/questions/187998/row-offset-in-sql-server). – Weihui Guo Aug 04 '17 at 16:08

2 Answers2

4

I suggest using Troy Goode's PagedList, also you can do this manually yourself but that would be reinventing the wheel.

Hamid Mosalla
  • 3,279
  • 2
  • 28
  • 51
2

I suggest using skip() and take() function should be do pagination. When you call this function pass page-no and no-of Record. And calculate records starting and display. example you want display 2 page and 50 records then linq query like this

var items =contex.employee.skip(50).take(50);

you want display 3 page and 50 records then linq query like this

var items =contex.employee.skip(100).take(50);
Mukesh Kalgude
  • 4,814
  • 2
  • 17
  • 32
  • actually this record count can be vary , I cannot decide how many pages are there , but definitely only 10 records per page , is that possible to it your way ? – kez Jul 10 '15 at 05:51
  • Yes first you can run query for count and decide total page and do this. – Mukesh Kalgude Jul 10 '15 at 05:53