I have a query generated from pivot , and i want to show the data in jquery data table but not able to do so.
- public ActionResult LoadData()
- {
- using (DHIFeedbackEntities2 Ms = new DHIFeedbackEntities2())
- {
-
-
- var summary = Ms.FeedBacks.SqlQuery(@"SELECT *
- FROM
- (
- SELECT
- YEAR([FeedBackDate])[Year],DATENAME(MONTH, [FeedBackDate])[Month],
- COUNT(1)[FeedbackID]
- FROM
- [DHIFeedback].[dbo].[FeedBack]
- GROUP BY
- YEAR([FeedBackDate]
- ),
- DATENAME(MONTH, [FeedBackDate])) AS Monthlyupdate
- PIVOT(SUM([FeedbackID]) FOR Month IN([January],[February],[March],[April],[May],
- [June],[July],[August],[September],[October],[November],[December])) AS MNamePivot
- order by 1,2").ToList<FeedBack>();
-
- return Json(new { data = summary }, JsonRequestBehavior.AllowGet);
-
-
- }
- }
- <script type="text/javascript">
- $(document).ready(function () {
- $('#Summary').DataTable({
-
- "processing": true,
-
- "ajax": {
- "url": "/Summary/LoadData",
- "type": "GET",
- "datatype": "json",
-
- },
- "lengthMenu": [
- [5, 10, 25, 50, 100, -1],
- [5, 10, 25, 50, 100, "All"]
- ],
- "autoWidth": true,
- "responsive": true,
- "lengthChange": true,
- "ordering": true,
-
-
-
-
-
- "columns": [
-
- { "data":"Year", "autoWidth": true },
- { "data":"January", "autoWidth": true },
- { "data":"February", "autoWidth": true },
- { "data":"March", "autoWidth": true },
- { "data":"April", "autoWidth": true },
- { "data":"May", "autoWidth": true },
- { "data":"June", "autoWidth": true },
- { "data":"July", "autoWidth": true },
- { "data":"August", "autoWidth": true },
- { "data":"September", "autoWidth": true },
- { "data":"October", "autoWidth": true },
- { "data":"November", "autoWidth": true },
- { "data":"December", "autoWidth": true }
- ]
- });
- });
- </script>