I have a requirement where I have to return 218034 records in a JSONRESULT object. This is used to bind to a datatable in jqwidgets. When I return around 5000 records it works fine but when I try to retrieve around 218034, I get a message on the datatable as "No data to display."
My Code in the Controller page:
public JsonResult GetProducts()
{
var dbResult = db.Products.ToList();
var products = (from product in dbResult
select new
{
product.ProductID,
product.ProductDesc,
product.ProductNumber
});
return Json(products, JsonRequestBehavior.AllowGet);
}
My Code in the View:
@{
ViewBag.Title = "jQWidgets DataTable";
}
@section scripts {
<script type="text/javascript">
$(document).ready(function () {
// prepare the data
var source =
{
dataType: "json",
dataFields: [
{ name: 'ProductDesc', type: 'string' },
{ name: 'ProductNumber', type: 'string' },
],
id: 'ProductID',
url: '/Product/GetProducts'
};
var dataAdapter = new $.jqx.dataAdapter(source);
// create Tree Grid
$("#dataTable").jqxDataTable(
{
width: 1000,
source: dataAdapter,
theme: 'shinyblack',
pageSize: 10,
sortable: true,
filterable: true,
pageable: true,
columns: [
{ text: 'Product', dataField: 'ProductDesc', width: 200 },
{ text: 'Product Number', dataField: 'ProductNumber', width: 200 },
]
});
});
</script>
}
<div id="dataTable"></div>
Can anyone please suggest what would be the best approach to show the large data. I am using MVC, jqwidgets.
May be the problem is that you've exceeded the MaxJsonLength. There's a help topic about that asp.net-largejsonresult