|
キーマップ
クライアント側スクリプトで提供されるAddKeyMapメソッドを使用すると
次のセル/行、前のセル/行、最初の列、最後の列への移動などのアクションを発生させるキーボードのキーをマップできます。
また、指定した列にスクロールすることもできます。
[Tab]キー :
次の列に移動
次の行に移動
[Enter]キー:
次の列に移動
次の行に移動
| 製品ID | 製品分類 | 製品名 | 前年比 | 4月 | 5月 | 6月 | 7月 | 8月 | 9月 |
1 | 10001 | 乳製品 | 酪農ミルク | | 5,500 | 5,000 | 4,500 | 6,000 | 5,500 | 5,000 |
2 | 20001 | 清涼飲料水 | いよかんドリンク | | 1,000 | 3,000 | 2,700 | 2,700 | 1,000 | 3,000 |
3 | 20002 | 清涼飲料水 | ぶどうジュース | | 3,000 | 3,500 | 4,800 | 4,800 | 3,000 | 3,500 |
4 | 20003 | 清涼飲料水 | マンゴードリンク | | 2,000 | 1,000 | 500 | 1,050 | 2,000 | 1,000 |
5 | 30001 | ビール | 激辛ビール | | 5,500 | 8,000 | 8,500 | 10,000 | 5,500 | 8,000 |
6 | 30002 | ビール | モルトビール | | 3,000 | 3,500 | 2,780 | 4,000 | 3,000 | 3,500 |
7 | 20004 | 清涼飲料水 | ぶどうの街 | | 500 | 300 | 200 | 700 | 500 | 300 |
8 | 30003 | ビール | オリエントの村 | | 8,000 | 9,500 | 9,580 | 9,000 | 8,000 | 9,500 |
9 | 40002 | 焼酎 | 吟醸 ほめごろし | | 6,000 | 7,000 | 9,000 | 9,500 | 6,000 | 7,000 |
10 | 40003 | 焼酎 | 大吟醸 オリエント | | 1,000 | 5,000 | 6,000 | 5,000 | 1,000 | 5,000 |
11 | 40005 | 焼酎 | 麦焼酎 ちこちこ | | 1,000 | 1,500 | 1,200 | 1,258 | 1,000 | 1,500 |
12 | 10002 | 乳製品 | 酪農ミルク(低脂肪) | | 501 | 202 | 380 | 456 | 501 | 202 |
13 | 30004 | ビール | オリエントの里 | | 963 | 256 | 365 | 554 | 868 | 853 |
14 | 30005 | ビール | オリエントからの便り | | 5,452 | 3,366 | 2,563 | 3,336 | 5,584 | 3,333 |
15 | 30006 | ビール | オリエントの森 | | 103 | 965 | 365 | 885 | 757 | 744 |
16 | 30007 | ビール | オリエントの町 | | 3,654 | 6,545 | 3,254 | 9,656 | 1,234 | 1,234 |
17 | 30008 | ビール | オリエントの未来都市 | | 4,567 | 4,454 | 3,654 | 5,987 | 6,536 | 6,633 |
|
ソースコード
別ウィンドウで表示
using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
public partial class clientaddkeymap : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string js = "var spid='" + FpSpread1.ClientID + "';";
ClientScript.RegisterStartupScript(this.GetType(), "onStartUpScript", js, true);
if (IsPostBack) return;
// セル型の自動設定を無効化
FpSpread1.ActiveSheetView.DataAutoCellTypes = false;
// データ連結
DataSet ds = new DataSet();
ds.ReadXml(MapPath("../App_Data/datanum3.xml"));
FpSpread1.DataSource = ds;
// SPREAD初期化
InitSpread(FpSpread1.Sheets[0]);
}
private void InitSpread(FarPoint.Web.Spread.SheetView sheet)
{
int i;
// SPREAD設定
sheet.FpSpread.CommandBar.Visible = false;
sheet.FpSpread.CssClass = "spreadStyle";
sheet.FpSpread.ShowFocusRectangle = true;
sheet.FpSpread.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.PageSize = sheet.RowCount;
// 列幅の設定
sheet.Columns[0].Width = 45;
sheet.Columns[1].Width = 85;
sheet.Columns[2].Width = 140;
sheet.Columns[3].Width = 40;
sheet.Columns[4].Width = 65;
sheet.Columns[5].Width = 65;
sheet.Columns[6].Width = 65;
sheet.Columns[7].Width = 65;
sheet.Columns[8].Width = 65;
sheet.Columns[9].Width = 65;
// 縦方向の揃え位置を中央に設定
sheet.DefaultStyle.VerticalAlign = VerticalAlign.Middle;
// 各列のセル型を設定
FarPoint.Web.Spread.GeneralCellType gnr = new FarPoint.Web.Spread.GeneralCellType();
gnr.FormatString = "#,##0";
sheet.Columns[4, 9].CellType = gnr;
sheet.Columns[4, 9].HorizontalAlign = HorizontalAlign.Right;
sheet.Columns[3].HorizontalAlign = HorizontalAlign.Center;
sheet.Columns[3].VerticalAlign = VerticalAlign.Middle;
FarPoint.Web.Spread.ImageCellType icUp = new FarPoint.Web.Spread.ImageCellType();
icUp.ImageUrl = "../images/uparrow.png";
FarPoint.Web.Spread.ImageCellType icSmallUp = new FarPoint.Web.Spread.ImageCellType();
icSmallUp.ImageUrl = "../images/smalluparrow.png";
FarPoint.Web.Spread.ImageCellType icDown = new FarPoint.Web.Spread.ImageCellType();
icDown.ImageUrl = "../images/downarrow.png";
FarPoint.Web.Spread.ImageCellType icSmallDown = new FarPoint.Web.Spread.ImageCellType();
icSmallDown.ImageUrl = "../images/smalldownarrow.png";
for (i = 0; i < sheet.RowCount; i++)
{
if (sheet.Cells[i, 3].Value.ToString() == "◎")
{
sheet.Cells[i, 3].CellType = icUp;
}
else if (sheet.Cells[i, 3].Value.ToString() == "○")
{
sheet.Cells[i, 3].CellType = icSmallUp;
}
else if (sheet.Cells[i, 3].Value.ToString() == "△")
{
sheet.Cells[i, 3].CellType = icSmallDown;
}
else if (sheet.Cells[i, 3].Value.ToString() == "×")
{
sheet.Cells[i, 3].CellType = icDown;
}
sheet.Cells[i, 3].Value = "";
}
}
}
|
Partial Public Class clientaddkeymap
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim js As String = "var spid='" + FpSpread1.ClientID & "';"
ClientScript.RegisterStartupScript(Me.GetType(), "onStartUpScript", js, True)
If IsPostBack Then
Return
End If
' セル型の自動設定を無効化
FpSpread1.ActiveSheetView.DataAutoCellTypes = False
' データ連結
Dim ds As New System.Data.DataSet()
ds.ReadXml(MapPath("../App_Data/datanum3.xml"))
FpSpread1.DataSource = ds
' SPREAD初期化
InitSpread(FpSpread1.Sheets(0))
End Sub
Private Sub InitSpread(sheet As FarPoint.Web.Spread.SheetView)
Dim i As Integer
' SPREAD設定
sheet.FpSpread.CommandBar.Visible = False
sheet.FpSpread.CssClass = "spreadStyle"
sheet.FpSpread.ShowFocusRectangle = True
sheet.FpSpread.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.PageSize = sheet.RowCount
' 列幅の設定
sheet.Columns(0).Width = 45
sheet.Columns(1).Width = 85
sheet.Columns(2).Width = 140
sheet.Columns(3).Width = 40
sheet.Columns(4).Width = 65
sheet.Columns(5).Width = 65
sheet.Columns(6).Width = 65
sheet.Columns(7).Width = 65
sheet.Columns(8).Width = 65
sheet.Columns(9).Width = 65
' 縦方向の揃え位置を中央に設定
sheet.DefaultStyle.VerticalAlign = VerticalAlign.Middle
' 各列のセル型を設定
Dim gnr As New FarPoint.Web.Spread.GeneralCellType()
gnr.FormatString = "#,##0"
sheet.Columns(4, 9).CellType = gnr
sheet.Columns(4, 9).HorizontalAlign = HorizontalAlign.Right
sheet.Columns(3).HorizontalAlign = HorizontalAlign.Center
sheet.Columns(3).VerticalAlign = VerticalAlign.Middle
Dim icUp As New FarPoint.Web.Spread.ImageCellType()
icUp.ImageUrl = "../images/uparrow.png"
Dim icSmallUp As New FarPoint.Web.Spread.ImageCellType()
icSmallUp.ImageUrl = "../images/smalluparrow.png"
Dim icDown As New FarPoint.Web.Spread.ImageCellType()
icDown.ImageUrl = "../images/downarrow.png"
Dim icSmallDown As New FarPoint.Web.Spread.ImageCellType()
icSmallDown.ImageUrl = "../images/smalldownarrow.png"
For i = 0 To sheet.RowCount - 1
If sheet.Cells(i, 3).Value.ToString() = "◎" Then
sheet.Cells(i, 3).CellType = icUp
ElseIf sheet.Cells(i, 3).Value.ToString() = "○" Then
sheet.Cells(i, 3).CellType = icSmallUp
ElseIf sheet.Cells(i, 3).Value.ToString() = "△" Then
sheet.Cells(i, 3).CellType = icSmallDown
ElseIf sheet.Cells(i, 3).Value.ToString() = "×" Then
sheet.Cells(i, 3).CellType = icDown
End If
sheet.Cells(i, 3).Value = ""
Next
End Sub
End Class
|
<%@ Page MasterPageFile="~/MasterPage.master" Language="c#" AutoEventWireup="true"
Inherits="clientaddkeymap" CodeFile="clientaddkeymap.aspx.cs" %>
<%@ Register Assembly="FarPoint.Web.SpreadJ" Namespace="FarPoint.Web.Spread" TagPrefix="FarPoint" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeaderPlaceHolder1" Runat="Server">
<script type="text/javascript">
function setKeyMap(e) {
var s = document.getElementById(spid);
var e = e || window.event;
var rd = e.target || e.srcElement;
var kcode;
if (rd.name == "tab")
kcode = 9;
if (rd.name == "enter")
kcode = 13;
if (!(rd.id.indexOf("col") < 0)) {
s.AddKeyMap(kcode, false, false, false, "element.MoveToNextCell()");
s.AddKeyMap(kcode, false, true, false, "element.MoveToPrevCell()");
}
if (!(rd.id.indexOf("row") < 0)) {
s.AddKeyMap(kcode, false, false, false, "element.MoveToNextRow()");
s.AddKeyMap(kcode, false, true, false, "element.MoveToPrevRow()");
}
s.focus();
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div style="position: relative; font-size:90%;">
[Tab]キー :
<input id="rdtabcol" style="position: static" type="radio" name="tab" checked="checked" onclick="setKeyMap(event);"/>
次の列に移動
<input id="rdtabrow" style="position: static" type="radio" name="tab" onclick="setKeyMap(event);"/>
次の行に移動
</div>
<div style="position: relative; font-size:90%;">
[Enter]キー:
<input id="rdentercol" style="position: static" type="radio" name="enter" onclick="setKeyMap(event);"/>
次の列に移動
<input id="rdenterrow" style="position: static" type="radio" name="enter" onclick="setKeyMap(event);"/>
次の行に移動
</div>
<farpoint:FpSpread ID="FpSpread1" runat="server" BorderColor="#A0A0A0" BorderStyle="Solid"
BorderWidth="1px">
<CommandBar BackColor="#F6F6F6" ButtonFaceColor="Control" ButtonHighlightColor="ControlLightLight"
ButtonShadowColor="ControlDark" />
<Sheets>
<farpoint:SheetView SheetName="Sheet1">
</farpoint:SheetView>
</Sheets>
</farpoint:FpSpread>
</asp:Content>
|
|