why dont u try Jquery Datatable for this.
here is an example
<script scr="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<table id="myDataTable">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody></tbody>
</table>
<script type="text/javascript">
$('#myDataTable').dataTable({
"bServerSide": true,
"sAjaxSource": "Home/AjaxHandler",
"bProcessing": true,
"aoColumns": [
{
"sName": "Id",
"bSearchable": false,
"bSortable": false,
"mRender": function (data, type, full) {
return '<a href="' + data + '">View</a>';
}
},
{ "sName": "Name" },
{ "sName": "Description" },
]
}); </script>
In controller
[ActionLogAttribute]
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult AjaxHandler(jQueryDataTableParamModel param)
{
return Json(new
{
sEcho = param.sEcho,
iTotalRecords = 97,
iTotalDisplayRecords = 3,
aaData = new List<string[]>() {
new string[] {"1", "Microsoft", "Redmond", "USA"},
new string[] {"2", "Google", "Mountain View", "USA"},
new string[] {"3", "Gowi", "Pancevo", "Serbia"}
}
},
JsonRequestBehavior.AllowGet);
}
}
public class jQueryDataTableParamModel
{
public string sEcho { get; set; }
public string sSearch { get; set; }
public int iDisplayLength { get; set; }
public int iDisplayStart { get; set; }
public int iColumns { get; set; }
public int iSortingCols { get; set; }
public string sColumns { get; set; }
}
jQueryDataTableParamModel
this class is used for passing the parameter from datatable to the server side function like page number,sorting column etc,
hope this help..