|
子階層シートのページング
子階層シートにおいても、ページングが可能です。
ChildViewCreatedイベントにて、ページサイズを設定することができます。
| 製品ID | 製品種別 | 製品名 | 当年第1Q | 当年第2Q | 当年第3Q | 当年第4Q |
1
| 10001 | 乳製品 | 酪農ミルク | 5,500 | 5,000 | 4,500 | 6,000 |
|
1 | 1990年度 | 2000 | 1000 | 4023 | 5230 |
2 | 1991年度 | 2000 | 1000 | 4023 | 5230 |
3 | 1992年度 | 2000 | 1000 | 4023 | 5230 |
4 | 1993年度 | 2000 | 1000 | 4023 | 5230 |
5 | 1994年度 | 2000 | 1000 | 4023 | 5230 |
|
|
2
| 20001 | 清涼飲料水 | いよかんドリンク | 1,000 | 3,000 | 2,700 | 2,700 |
3
| 20002 | 清涼飲料水 | ぶどうジュース | 3,000 | 3,500 | 4,800 | 4,800 |
4
| 20003 | 清涼飲料水 | マンゴードリンク | 2,000 | 1,000 | 500 | 1,050 |
5
| 30001 | ビール | 激辛ビール | 5,500 | 8,000 | 8,500 | 10,000 |
|
|
ソースコード
別ウィンドウで表示
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class hierarchy_hierarchicalpaging : System.Web.UI.Page
{
System.Data.DataSet myDataSet = new System.Data.DataSet();
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack) return;
// セル型の自動設定を無効化
FpSpread1.ActiveSheetView.DataAutoCellTypes = false;
// データ作成
InitData();
FpSpread1.DataSource = myDataSet;
// SPREAD初期化
InitSpread(FpSpread1.Sheets[0]);
FpSpread1.Sheets[0].ExpandRow(0, true);
}
private void InitSpread(FarPoint.Web.Spread.SheetView sheet)
{
// SPREAD設定
FpSpread1.CssClass = "spreadStyle";
FpSpread1.UseClipboard = false;
// フォントサイズの設定
sheet.DefaultStyle.Font.Size = FontUnit.Parse("80%");
sheet.ColumnHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%");
sheet.RowHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%");
sheet.SheetCorner.DefaultStyle.Font.Size = FontUnit.Parse("80%");
// 列幅の設定
sheet.Columns[0].Width = 50;
sheet.Columns[1].Width = 100;
sheet.Columns[2].Width = 124;
sheet.Columns[3].Width = 80;
sheet.Columns[4].Width = 80;
sheet.Columns[5].Width = 80;
sheet.Columns[6].Width = 80;
// 縦方向の揃え位置を中央に設定
sheet.DefaultStyle.VerticalAlign = VerticalAlign.Middle;
}
private void InitData()
{
System.Data.DataTable thisyear, lastyear;
int i;
// 当年度データ
thisyear = myDataSet.Tables.Add("thisyear");
thisyear.Columns.AddRange(new System.Data.DataColumn[] { new System.Data.DataColumn("製品ID",Type.GetType("System.String")),
new System.Data.DataColumn("製品種別", Type.GetType("System.String")),
new System.Data.DataColumn("製品名", Type.GetType("System.String")),
new System.Data.DataColumn("当年第1Q", Type.GetType("System.Int32")) ,
new System.Data.DataColumn("当年第2Q", Type.GetType("System.Int32")) ,
new System.Data.DataColumn("当年第3Q", Type.GetType("System.Int32")) ,
new System.Data.DataColumn("当年第4Q", Type.GetType("System.Int32"))
});
thisyear.Rows.Add(new Object[] { "10001", "乳製品", "酪農ミルク", 5500, 5000, 4500, 6000 });
thisyear.Rows.Add(new Object[] { "20001", "清涼飲料水", "いよかんドリンク", 1000, 3000, 2700, 2700 });
thisyear.Rows.Add(new Object[] { "20002", "清涼飲料水", "ぶどうジュース", 3000, 3500, 4800, 4800 });
thisyear.Rows.Add(new Object[] { "20003", "清涼飲料水", "マンゴードリンク", 2000, 1000, 500, 1050 });
thisyear.Rows.Add(new Object[] { "30001", "ビール", "激辛ビール", 5500, 8000, 8500, 10000 });
lastyear = myDataSet.Tables.Add("lastyear");
lastyear.Columns.AddRange(new System.Data.DataColumn[] { new System.Data.DataColumn("製品ID",Type.GetType("System.String")),
new System.Data.DataColumn("年度", Type.GetType("System.String")),
new System.Data.DataColumn("第1Q", Type.GetType("System.Int32")) ,
new System.Data.DataColumn("第2Q", Type.GetType("System.Int32")) ,
new System.Data.DataColumn("第3Q", Type.GetType("System.Int32")) ,
new System.Data.DataColumn("第4Q", Type.GetType("System.Int32"))
});
for (i = 0; i < 20; i++)
{
lastyear.Rows.Add(new Object[] { "10001", Convert.ToString(i + 1990) + "年度", 2000, 1000, 4023, 5230 });
lastyear.Rows.Add(new Object[] { "20001", Convert.ToString(i + 1990) + "年度", 1050, 2000, 2500, 2600 });
lastyear.Rows.Add(new Object[] { "20002", Convert.ToString(i + 1990) + "年度", 3600, 2400, 1200, 1600 });
lastyear.Rows.Add(new Object[] { "20003", Convert.ToString(i + 1990) + "年度", 1600, 1250, 356, 1020 });
lastyear.Rows.Add(new Object[] { "30001", Convert.ToString(i + 1990) + "年度", 5600, 5000, 2500, 1900 });
}
// リレーションシップを設定します。
myDataSet.Relations.Add("prddata", thisyear.Columns["製品ID"], lastyear.Columns["製品ID"]);
}
protected void FpSpread1_ChildViewCreated(object sender, FarPoint.Web.Spread.CreateChildViewEventArgs e)
{
FarPoint.Web.Spread.SheetView sv = e.SheetView;
switch (sv.RelationName)
{
case "prddata":
sv.AllowPage = true;
sv.PageSize = 5;
sv.FpSpread.Pager.Mode = FarPoint.Web.Spread.PagerMode.Both;
// フォントサイズの設定
sv.DefaultStyle.Font.Size = FontUnit.Parse("80%");
sv.ColumnHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%");
sv.RowHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%");
sv.SheetCorner.DefaultStyle.Font.Size = FontUnit.Parse("80%");
sv.Columns[0].Visible = false;
sv.ColumnHeader.Visible = false;
sv.RowHeader.Columns[0].Width = 50;
sv.Columns[1].Width = 224;
sv.Columns[2].Width = 80;
sv.Columns[3].Width = 80;
sv.Columns[4].Width = 80;
sv.Columns[5].Width = 80;
if (sv.ActiveRow == -1)
{
sv.ActiveRow = 0;
sv.ActiveColumn = 0;
}
break;
}
}
}
|
Partial Class hierarchy_hierarchicalpaging
Inherits System.Web.UI.Page
Private myDataSet As New System.Data.DataSet()
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack Then
Return
End If
' セル型の自動設定を無効化
FpSpread1.ActiveSheetView.DataAutoCellTypes = False
' データ作成
InitData()
FpSpread1.DataSource = myDataSet
' SPREAD初期化
InitSpread(FpSpread1.Sheets(0))
FpSpread1.Sheets(0).ExpandRow(0, True)
End Sub
Private Sub InitSpread(ByVal sheet As FarPoint.Web.Spread.SheetView)
' SPREAD設定
FpSpread1.CssClass = "spreadStyle"
FpSpread1.UseClipboard = False
' フォントサイズの設定
sheet.DefaultStyle.Font.Size = FontUnit.Parse("80%")
sheet.ColumnHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%")
sheet.RowHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%")
sheet.SheetCorner.DefaultStyle.Font.Size = FontUnit.Parse("80%")
' 列幅の設定
sheet.Columns(0).Width = 50
sheet.Columns(1).Width = 100
sheet.Columns(2).Width = 124
sheet.Columns(3).Width = 80
sheet.Columns(4).Width = 80
sheet.Columns(5).Width = 80
sheet.Columns(6).Width = 80
' 縦方向の揃え位置を中央に設定
sheet.DefaultStyle.VerticalAlign = VerticalAlign.Middle
End Sub
Private Sub InitData()
Dim thisyear As System.Data.DataTable, lastyear As System.Data.DataTable
Dim i As Integer
' 当年度データ
thisyear = myDataSet.Tables.Add("thisyear")
thisyear.Columns.AddRange(New System.Data.DataColumn() {New System.Data.DataColumn("製品ID", Type.GetType("System.String")), New System.Data.DataColumn("製品種別", Type.GetType("System.String")), New System.Data.DataColumn("製品名", Type.GetType("System.String")), New System.Data.DataColumn("当年第1Q", Type.GetType("System.Int32")), New System.Data.DataColumn("当年第2Q", Type.GetType("System.Int32")), New System.Data.DataColumn("当年第3Q", Type.GetType("System.Int32")), New System.Data.DataColumn("当年第4Q", Type.GetType("System.Int32"))})
thisyear.Rows.Add(New [Object]() {"10001", "乳製品", "酪農ミルク", 5500, 5000, 4500, 6000})
thisyear.Rows.Add(New [Object]() {"20001", "清涼飲料水", "いよかんドリンク", 1000, 3000, 2700, 2700})
thisyear.Rows.Add(New [Object]() {"20002", "清涼飲料水", "ぶどうジュース", 3000, 3500, 4800, 4800})
thisyear.Rows.Add(New [Object]() {"20003", "清涼飲料水", "マンゴードリンク", 2000, 1000, 500, 1050})
thisyear.Rows.Add(New [Object]() {"30001", "ビール", "激辛ビール", 5500, 8000, 8500, 10000})
lastyear = myDataSet.Tables.Add("lastyear")
lastyear.Columns.AddRange(New System.Data.DataColumn() {New System.Data.DataColumn("製品ID", Type.GetType("System.String")), New System.Data.DataColumn("年度", Type.GetType("System.String")), New System.Data.DataColumn("第1Q", Type.GetType("System.Int32")), New System.Data.DataColumn("第2Q", Type.GetType("System.Int32")), New System.Data.DataColumn("第3Q", Type.GetType("System.Int32")), New System.Data.DataColumn("第4Q", Type.GetType("System.Int32"))})
For i = 0 To 19
lastyear.Rows.Add(New [Object]() {"10001", Convert.ToString(i + 1990) & "年度", 2000, 1000, 4023, 5230})
lastyear.Rows.Add(New [Object]() {"20001", Convert.ToString(i + 1990) & "年度", 1050, 2000, 2500, 2600})
lastyear.Rows.Add(New [Object]() {"20002", Convert.ToString(i + 1990) & "年度", 3600, 2400, 1200, 1600})
lastyear.Rows.Add(New [Object]() {"20003", Convert.ToString(i + 1990) & "年度", 1600, 1250, 356, 1020})
lastyear.Rows.Add(New [Object]() {"30001", Convert.ToString(i + 1990) & "年度", 5600, 5000, 2500, 1900})
Next
' リレーションシップを設定します。
myDataSet.Relations.Add("prddata", thisyear.Columns("製品ID"), lastyear.Columns("製品ID"))
End Sub
Protected Sub FpSpread1_ChildViewCreated(ByVal sender As Object, ByVal e As FarPoint.Web.Spread.CreateChildViewEventArgs) Handles FpSpread1.ChildViewCreated
Dim sv As FarPoint.Web.Spread.SheetView = e.SheetView
Select Case sv.RelationName
Case "prddata"
sv.AllowPage = True
sv.PageSize = 5
sv.FpSpread.Pager.Mode = FarPoint.Web.Spread.PagerMode.Both
' フォントサイズの設定
sv.DefaultStyle.Font.Size = FontUnit.Parse("80%")
sv.ColumnHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%")
sv.RowHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%")
sv.SheetCorner.DefaultStyle.Font.Size = FontUnit.Parse("80%")
sv.Columns(0).Visible = False
sv.ColumnHeader.Visible = False
sv.RowHeader.Columns(0).Width = 50
sv.Columns(1).Width = 224
sv.Columns(2).Width = 80
sv.Columns(3).Width = 80
sv.Columns(4).Width = 80
sv.Columns(5).Width = 80
If sv.ActiveRow = -1 Then
sv.ActiveRow = 0
sv.ActiveColumn = 0
End If
Exit Select
End Select
End Sub
End Class
|
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="hierarchicalpaging.aspx.cs" Inherits="hierarchy_hierarchicalpaging" %>
<%@ Register Assembly="FarPoint.Web.SpreadJ" Namespace="FarPoint.Web.Spread" TagPrefix="FarPoint" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeaderPlaceHolder1" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="#A0A0A0" BorderStyle="Solid"
BorderWidth="1px" onchildviewcreated="FpSpread1_ChildViewCreated">
<CommandBar BackColor="#F6F6F6" ButtonFaceColor="Control" ButtonHighlightColor="ControlLightLight"
ButtonShadowColor="ControlDark">
</CommandBar>
<Sheets>
<FarPoint:SheetView SheetName="Sheet1">
</FarPoint:SheetView>
</Sheets>
</FarPoint:FpSpread>
</asp:Content>
|
|