製品版のみの機能
ピボット データ セレクター - ASP.NET MVC フラット データ バインディング
このサンプルでは、igOlapFlatDataSource に ASP.NET MVC ヘルパーを使用し、このデータ ソースを igPivotDataSelector および igPivotGrid に使用する方法を紹介します。
このサンプルは CTP 機能を使用しています。製品版では、API や動作が変更される場合があります。
このサンプルは、より大きい画面サイズのためにデザインされました。
モバイル デバイスで画面を回転、フル サイズ表示、またはその他のデバイスにメールで送信します。
コード ビュー
クリップボードへコピー
@using Infragistics.Web.Mvc @using IgniteUI.SamplesBrowser.Models <!DOCTYPE html> <html> <head> <title></title> <!-- Ignite UI for jQuery Required Combined CSS Files --> <link href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" /> <link href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/structure/infragistics.css" rel="stylesheet" /> <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script> <!-- Ignite UI for jQuery Required Combined JavaScript Files --> <script src="http://cdn-na.infragistics.com/igniteui/2024.1/latest/js/infragistics.core.js"></script> <script src="http://cdn-na.infragistics.com/igniteui/2024.1/latest/js/infragistics.lob.js"></script> <style> #dataSelector, #pivotGrid { float: left; } </style> </head> <body> <div class="sampleContent"> @(Html.Infragistics().OlapDataSource().ID("flatDataSource") .DataSourceOptions( dataSourceOptions => dataSourceOptions .Columns("[Location].[Location]") .Rows("[Dates].[RequiredDate]") .Measures("[Measures].[Freight]") .FlatDataOptions(flatOptions => flatOptions.Metadata( metadata => metadata.Cube(cube => cube.Name("Invoices").Caption("請求書") .MeasuresDimension(measuresDimension => measuresDimension.Caption("メジャー").Measures( measures => { measures.AddMeasure().Name("Quantity").Caption("数量").Aggregator("$.ig.OlapUtilities.prototype.sumAggregator('Quantity')"); measures.AddMeasure().Name("Freight").Caption("発送").Aggregator("$.ig.OlapUtilities.prototype.sumAggregator('Freight', 2)"); measures.AddMeasure().Name("Discount").Caption("割引").Aggregator("$.ig.OlapUtilities.prototype.sumAggregator('Discount', 2)"); })) .Dimensions(dimensions => { dimensions.AddDimension().Name("Location").Caption("位置").Hierarchies( hierarchies => hierarchies.AddHierarchy().Name("Location").Caption("位置").Levels(levels => { levels.AddLevel().Name("AllLocations").Caption("すべての場所") .MemberProvider("function(item) {return 'すべての場所';}"); levels.AddLevel().Name("ShipCountry").Caption("国") .MemberProvider("function(item) {return item.ShipCountry; }"); levels.AddLevel().Name("City").Caption("市") .MemberProvider("function(item) {return item.City; }"); levels.AddLevel().Name("Address").Caption("住所") .MemberProvider("function(item) {return item.Address; }"); })); dimensions.AddDimension().Name("Dates").Caption("日付").Hierarchies( hierarchies => { hierarchies.AddHierarchy().Name("RequiredDate").Caption("配達日").Levels(levels => { levels.AddLevel().Name("AllPeriods").Caption("すべての期間").MemberProvider("function(item) { return 'すべての期間'; }"); levels.AddLevel().Name("Year").Caption("年").MemberProvider("$.ig.OlapUtilities.prototype.dateMemberProvider('year', 'RequiredDate')"); levels.AddLevel().Name("Quarter").Caption("四半期").MemberProvider("$.ig.OlapUtilities.prototype.dateMemberProvider('quarter', 'RequiredDate')"); levels.AddLevel().Name("Month").Caption("月").MemberProvider("$.ig.OlapUtilities.prototype.dateMemberProvider('month', 'RequiredDate')"); levels.AddLevel().Name("Date").Caption("日付").MemberProvider("$.ig.OlapUtilities.prototype.dateMemberProvider('date', 'RequiredDate')"); }); hierarchies.AddHierarchy().Name("ShippedDate").Caption("出荷日").Levels(levels => { levels.AddLevel().Name("AllPeriods").Caption("すべての期間").MemberProvider("function(item) { return 'すべての期間'; }"); levels.AddLevel().Name("Year").Caption("年").MemberProvider("$.ig.OlapUtilities.prototype.dateMemberProvider('year', 'ShippedDate')"); levels.AddLevel().Name("Quarter").Caption("四半期").MemberProvider("$.ig.OlapUtilities.prototype.dateMemberProvider('quarter', 'ShippedDate')"); levels.AddLevel().Name("Month").Caption("月").MemberProvider("$.ig.OlapUtilities.prototype.dateMemberProvider('month', 'ShippedDate')"); levels.AddLevel().Name("Date").Caption("日付").MemberProvider("$.ig.OlapUtilities.prototype.dateMemberProvider('date', 'ShippedDate')"); }); hierarchies.AddHierarchy().Name("OrderDate").Caption("注文日").Levels(levels => { levels.AddLevel().Name("AllPeriods").Caption("すべての期間").MemberProvider("function(item) { return 'すべての期間'; }"); levels.AddLevel().Name("Year").Caption("年").MemberProvider("$.ig.OlapUtilities.prototype.dateMemberProvider('year', 'OrderDate')"); levels.AddLevel().Name("Quarter").Caption("四半期").MemberProvider("$.ig.OlapUtilities.prototype.dateMemberProvider('quarter', 'OrderDate')"); levels.AddLevel().Name("Month").Caption("月").MemberProvider("$.ig.OlapUtilities.prototype.dateMemberProvider('month', 'OrderDate')"); levels.AddLevel().Name("Date").Caption("日付").MemberProvider("$.ig.OlapUtilities.prototype.dateMemberProvider('date', 'OrderDate')"); }); }); dimensions.AddDimension().Name("Customers").Caption("顧客").Hierarchies( hierarchies => hierarchies.AddHierarchy().Name("Customers").Caption("顧客").Levels(levels => { levels.AddLevel().Name("AllCustomers").Caption("すべての顧客") .MemberProvider("function(item) {return 'すべての顧客'; }"); levels.AddLevel().Name("CustomerName").Caption("顧客名") .MemberProvider("function(item) {return item.CustomerName; }"); })); dimensions.AddDimension().Name("Salespeople").Caption("営業担当者").Hierarchies( hierarchies => hierarchies.AddHierarchy().Name("Salespeople").Caption("営業担当者").Levels(levels => { levels.AddLevel().Name("AllSalespeople").Caption("すべての営業担当者") .MemberProvider("function(item) {return 'すべての営業担当者'; }"); levels.AddLevel().Name("Salesperson").Caption("営業担当者") .MemberProvider("function(item) {return item.Salesperson; }"); })); dimensions.AddDimension().Name("Shippers").Caption("出荷者").Hierarchies( hierarchies => hierarchies.AddHierarchy().Name("Shippers").Caption("出荷者").Levels(levels => { levels.AddLevel().Name("AllShippers").Caption("すべての出荷者") .MemberProvider("function(item) {return 'すべての出荷者'; }"); levels.AddLevel().Name("ShipperName").Caption("出荷名") .MemberProvider("function(item) {return item.ShipperName; }"); })); dimensions.AddDimension().Name("Products").Caption("製品").Hierarchies( hierarchies => hierarchies.AddHierarchy().Name("Products").Caption("製品").Levels(levels => { levels.AddLevel().Name("AllProducts").Caption("すべての製品") .MemberProvider("function(item) {return 'すべての製品'; }"); levels.AddLevel().Name("Product").Caption("製品") .MemberProvider("function(item) {return item.ProductName; }"); })); }))) .DataSource(this.Model) .DataBind())) .Render()) @(Html.Infragistics().PivotDataSelector().Width("230px").Height("580px").DataSourceID("flatDataSource").ID("dataSelector").Render()) @(Html.Infragistics().PivotGrid().Width("580px").Height("580px").DataSourceID("flatDataSource").ID("pivotGrid").Render()) </div> </body> </html>
using System.Web.Mvc; using Infragistics.Web.Mvc; using IgniteUI.SamplesBrowser.Application.Data; using System.Data; using System.Data.SqlClient; using IgniteUI.SamplesBrowser.Models.Repositories; using Newtonsoft.Json.Converters; using System.Linq; using System; namespace IgniteUI.SamplesBrowser.Controllers { public class PivotDataSelectorController : Controller { [ActionName("using-the-asp-net-mvc-helper-with-flat-data-source")] public ActionResult UsingAspNetMvcHelperWithFlatDataSource() { var invoices = RepositoryFactory.GetInvoiceRepository().Get().Take(200).Select(invoice => new { Address = invoice.Address, City = invoice.City, CustomerName = invoice.CustomerName, Discount = invoice.Discount, Freight = invoice.Freight, OrderDate = invoice.OrderDate == null ? null : invoice.OrderDate.Value.AddYears(16).ToShortDateString(), ProductName = invoice.ProductName, Quantity = invoice.Quantity, RequiredDate = invoice.RequiredDate == null ? null : invoice.RequiredDate.Value.AddYears(16).ToShortDateString(), Salesperson = invoice.Salesperson, ShipCountry = invoice.ShipCountry, ShippedDate = invoice.ShippedDate == null ? null : invoice.ShippedDate.Value.AddYears(16).ToShortDateString(), ShipperName = invoice.ShipperName }); return View("using-the-asp-net-mvc-helper-with-flat-data-source", invoices); } [ActionName("using-the-asp-net-mvc-helper-with-xmla-data-source")] public ActionResult UsingAspNetMvcHelperWithXmlaDataSource() { return View("using-the-asp-net-mvc-helper-with-xmla-data-source"); } } }