.NET application, how do I construct a proper Json string?
.NET application, how do I construct a proper Json string?
I just inherited a project using DataTables that has minimal commenting and original developer not available.
The project is a .NET MVC framework website and I'm trying to understand what is going on with the code in a controller.
I've cut almost all the goodies out of the following code block that works:
public ActionResult MyDataTable()
{
var result;
//get data, manipulate and stuff in result
return Json(new
{
Result = "Success",
iDisplayStart = 5,
sEcho = 1,
iTotalRecords = 2,
iTotalDisplayRecords = 2
, aaData = result
}, JsonRequestBehavior.AllowGet);
}
My question is what are iDisplayStart, sEcho, iTotalRecords, and iTotalDisplayRecords? And why are they hard coded?
Did the previous developer try to over-write the number of records, start page, etc to display?
Any help in understanding what just happened would be greatly appreciated.
Replies
I can't be much help, but I can at least point you to the "legacy" documentation:
https://legacy.datatables.net/ref
which is probably a good place to start.
Also, here is a thread about sEcho which may be useful.
https://datatables.net/forums/discussion/2087/secho-the-mystery-variable
No idea. There really shouldn't be if server-side processing is actually being used. If server-side processing in the table isn't being used, then those parameters are redundant and should be removed.
Allan