Bind jqxGrid to SQL Database using ASP.NET MVC3 and LargeJSONResult
In this help topic, we will use a custom JsonResult Class for ASP.Net MVC to avoid MaxJsonLength Exceeded Exception. The class is called LargeJsonResult.
Below is the implementation of the LargeJSONResult class:
In a Controller class called CustomersController, we will implement a method called GetCustomers which returns LargeJsonResult. If you are new to using the jqxGrid with ASP .NET MVC, you can take a look at this help topic:
jquery-grid-to-sql-database.htm.
public LargeJsonResult GetCustomers(){ var dbResult = db.Customers.ToList(); var customers = from customer in dbResult select new { customer.CompanyName, customer.ContactName, customer.ContactTitle, customer.Address, customer.City }; return new LargeJsonResult { Data = customers, JsonRequestBehavior = System.Web.Mvc.JsonRequestBehavior.AllowGet };}
The last step is to create and populate the jqxGrid with data.