ASP.NET MVC + Datatables ... 2 round trips
ASP.NET MVC + Datatables ... 2 round trips
I am looking for a way to resolve an issue that came up while load testing pages all using datatables and ASP.NET MVC. Upon load of a page (e.g. GET /Index) we load a datatable (server-side) in document.ready against a route in the same controller (e.g. GET /Data).
When dealing with high concurrency these 2 calls are unnecessary the first time a user lands on a page. This scenario is common for us, user loads page w/ datatable on it and clicks on something in the first page, linking to another page.
You CAN pass raw JSON into Javascript from MVC Razor code. Is it easy for each page in my sample to not double call when "GET /Index" is called, and just land with the JSON it needs? Then behave as a regular data table against the 'GET /Data' route moving forward?
-Steve
This question has an accepted answers - jump to answer
Answers
Have a look at the
deferLoading
option which will cause DataTables just to display the table as it was originally found in the HTML rather than making an Ajax request for the data.Allan
Thanks Allan, your response helped me find this thread and the solution:
http://datatables.net/forums/discussion/7319/can-you-initialize-the-datatable-with-json-data-when-serverside-true
I believe my question may clear up the ambiguity around the OP's rationale on that thread as well.
-Steve