From 2309ec3b440e56da0f57ca95ae222dc4f02ab8db Mon Sep 17 00:00:00 2001
From: ALMMa
Date: Wed, 19 Mar 2014 22:25:38 -0300
Subject: [PATCH] Added sample to return data as Json
Removed namespaces from sample code and added sample returning Json
data.
---
README.md | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index bd28b9e..38be034 100644
--- a/README.md
+++ b/README.md
@@ -21,10 +21,20 @@
```C#
-public ActionResult MyActionResult([ModelBinder(typeof(DataTables.Mvc.DataTablesBinder)] IDataTablesRequest requestModel)
+public ActionResult MyActionResult([ModelBinder(typeof(DataTablesBinder)] IDataTablesRequest requestModel)
{
// do your stuff...
- return new DataTablesResponse(requestModel.Draw, myFilteredData.Skip(requestModel.Start).Take(requestModel.Length), myFilteredData.Count(), myOriginalDataSet.Count());
+ var paged = myFilteredData.Skip(requestModel.Start).Take(requestModel.Length);
+ return new DataTablesResponse(requestModel.Draw, paged, myFilteredData.Count(), myOriginalDataSet.Count());
+}
+
+// Or if you'd like to return a JsonResult, try this:
+
+public JsonResult MyActionResult([ModelBinder(typeof(DataTablesBinder)] IDataTablesRequest requestModel)
+{
+ // do your stuff...
+ var paged = myFilteredData.Skip(requestModel.Start).Take(requestModel.Length);
+ return Json(new DataTablesResponse(requestModel.Draw, paged, myFilteredData.Count(), myOriginalDataSet.Count()));
}
```
Any gotchas?