일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- upbit
- 시트 탭 사라짐
- league of legends
- Banker's
- Aspose.cells
- 세로 스크롤 막대
- 업비트
- CSV
- .csv
- 썸머노트
- Kakao API Address
- Request.Form
- python
- MSSQL
- LEFT JOIN
- Oracle
- rounding
- 가로 스크롤 막대
- 일본여행
- Android
- 초딩수학
- swift 화면전환
- Excel
- 한글깨짐
- MS-SQL
- chart.js
- 나만의 상점
- Banker's rounding
- 스크롤 사라짐
- MYSQL
- Today
- Total
DBA
DevExtreme Pivot Grid Data Binding - Mvc() or WebApi() 본문
DevExtreme Pivot Grid Data Binding - Mvc() or WebApi()
코볼 2023. 1. 6. 14:53Mvc() 이용 :
Index.cshtml
----------------------------------------------------------------------------------------------------------------------------
@using DevExtremeMvcApp1.Models
@(Html.DevExtreme().PivotGrid<PGT_FactSalesQuotaResult>()
.ID("pivotGridContainer")
.AllowSortingBySummary(true)
.AllowFiltering(true)
.ShowBorders(true)
.ShowColumnGrandTotals(false)
.ShowRowGrandTotals(false)
.ShowRowTotals(false)
.ShowColumnTotals(false)
.FieldChooser(c => c.Enabled(true).Height(400))
.DataSource(d => d
.Store(s => s.Mvc().Controller("PivotGrid").LoadAction("PivotGridList").LoadParams(new { calendarYear = 9999 }))
.Fields(fields =>
{
fields.AddFor(m => m.Title)
.Width(120)
.Area(PivotGridArea.Row);
fields.AddFor(m => m.Date)
.Area(PivotGridArea.Column);
fields.AddFor(m => m.SalesAmountQuota)
.SummaryType(SummaryType.Sum)
.Format(Format.Currency)
.Area(PivotGridArea.Data);
})
)
)
----------------------------------------------------------------------------------------------------------------------------
PivotGridController.cs
----------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
// using 추가 : Models, Newtonsoft.Json
using DevExtremeMvcApp1.Models;
using Newtonsoft.Json;
namespace DevExtremeMvcApp1.Controllers
{
public class PivotGridController : Controller
{
// GET: PivotGrid
public ActionResult PivotGridList(short? calendarYear)
{
if (calendarYear == 9999)
{
calendarYear = null;
}
List<PGT_FactSalesQuotaResult> result;
using (PGTDataContext PGT = new PGTDataContext())
{
// stored procedure call
result = PGT.PGT_FactSalesQuota(calendarYear).ToList();
}
var resultJson = JsonConvert.SerializeObject(result);
return Content(resultJson, "application/json");
}
}
}
----------------------------------------------------------------------------------------------------------------------------
WebApi() 이용 :
Index.cshtml
----------------------------------------------------------------------------------------------------------------------------
@using DevExtremeMvcApp1.Models
@(Html.DevExtreme().PivotGrid<PGT_FactSalesQuotaResult>()
.ID("pivotGridContainerApi")
.AllowSortingBySummary(true)
.AllowFiltering(true)
.ShowBorders(true)
.ShowColumnGrandTotals(false)
.ShowRowGrandTotals(false)
.ShowRowTotals(false)
.ShowColumnTotals(false)
.FieldChooser(c => c.Enabled(true).Height(400))
.DataSource(d => d
.Store(s => s.WebApi().Controller("PivotGridApi").LoadAction("PivotGridList").LoadParams(new { calendarYear = 9999 }))
.Fields(fields =>
{
fields.AddFor(m => m.Title)
.Width(120)
.Area(PivotGridArea.Row);
fields.AddFor(m => m.Date)
.Area(PivotGridArea.Column);
fields.AddFor(m => m.SalesAmountQuota)
.SummaryType(SummaryType.Sum)
.Format(Format.Currency)
.Area(PivotGridArea.Data);
})
)
)
----------------------------------------------------------------------------------------------------------------------------
PivotGridApiController.cs - api controller로 만들어야 함.
----------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
// using 추가 : Models, DevExtreme.AspNet.Data, DevExtreme.AspNet.Mvc
using DevExtreme.AspNet.Data;
using DevExtreme.AspNet.Mvc;
using DevExtremeMvcApp1.Models;
namespace DevExtremeMvcApp1.Controllers
{
public class PivotGridApiController : ApiController
{
[HttpGet]
public HttpResponseMessage PivotGridList(short? calendarYear, DataSourceLoadOptions loadOptions)
{
if (calendarYear == 9999)
{
calendarYear = null;
}
List<PGT_FactSalesQuotaResult> result;
using (PGTDataContext PGT = new PGTDataContext())
{
// stored procedure call
result = PGT.PGT_FactSalesQuota(calendarYear).ToList();
}
return Request.CreateResponse(DataSourceLoader.Load(result, loadOptions));
}
}
}
----------------------------------------------------------------------------------------------------------------------------