TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sunny kumar
NA
333
9.5k
I want to show pivot query data in jquery data table
Mar 5 2019 3:53 AM
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 [DHIFeedback].[dbo].[FeedBack]").ToList<FeedBack>();
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>();
//foreach(var summ in data)
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
,
//"fnRowCallback": function (nRow, aData, iDisplayIndex) {
// var oSettings = this.fnSettings();
// $("td:first", nRow).html(oSettings._iDisplayStart + iDisplayIndex + 1);
// return nRow;
//},
"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>
Reply
Answers (
2
)
SQL Access: Calculate the total elimination of records not t
Explain real time use of delegates