カレンダー型セルで行追加後に他行の値を更新すると、追加した行の値が不正になる
対象製品
SPREAD for ASP.NET 8.0J
状況
修正済み
詳細
カレンダー型セルで行追加後に他行の値を更新すると、追加した行の値が不正になります。
【再現手順】
1.新規WebフォームにSPREAD、Button2つ、ObjectDataSourceを配置します
2.Webフォームに下記の再現コードを貼り付けます
3.ObjectDataSource用のビジネスオブジェクトとなるTestAClass.vbファイルを用意します
4.TestAClass.vbに下記のコード(TestAClass.vb)を張り付け、プロジェクトに追加します
5.TestAClass.vb のTestAClassをObjectDataSourceのビジネスオブジェクトとして設定します
6.TestAClassが参照するxml、test.xmlを用意しプロジェクトに追加します
7.test.xmlに下記の内容(test.xml)を張り付け、プロジェクトを起動します
8.2行目を選択しButton1(行の挿入)を押下します
9.挿入された2行目に左から"3"、"2012/08/01"、"2012/08/01"を入力します
10.既存の3行目の2列目、3列目を"2015/12/01"、"2015/12/01"に変更します
11.Button2(Updateの実行)を押下します
-- IntertTestメソッドの2列目の値が「手順10」で更新された値になります
【再現コード】
------------------------------------
Webフォームクラス
------------------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then Return
' FpSpread1の設定
FpSpread1.ActiveSheetView.AutoGenerateColumns = False
FpSpread1.ActiveSheetView.RowCount = 0
FpSpread1.ActiveSheetView.ColumnCount = 3
FpSpread1.ActiveSheetView.Columns(0).DataField = "ID"
FpSpread1.ActiveSheetView.Columns(1).DataField = "A1"
FpSpread1.ActiveSheetView.Columns(2).DataField = "A2"
FpSpread1.DataSourceID = "ObjectDataSource1"
Dim ajaxComboBox As FarPoint.Web.Spread.Extender.AjaxComboBoxCellType = New FarPoint.Web.Spread.Extender.AjaxComboBoxCellType()
ajaxComboBox.DropDownStyle = AjaxControlToolkit.ComboBoxStyle.DropDownList
ajaxComboBox.AutoCompleteMode = AjaxControlToolkit.ComboBoxAutoCompleteMode.SuggestAppend
ajaxComboBox.Items.Add("1")
ajaxComboBox.Items.Add("2")
ajaxComboBox.Items.Add("3")
FpSpread1.ActiveSheetView.Columns(0).CellType = ajaxComboBox
Dim dateCalendarCellType As FarPoint.Web.Spread.Extender.DateCalendarCellType = New FarPoint.Web.Spread.Extender.DateCalendarCellType()
dateCalendarCellType.DateFormat = "yyyy/MM/dd"
dateCalendarCellType.ShowEditor = True
dateCalendarCellType.TodaysDateFormat = "yyyy/MM/dd"
dateCalendarCellType.DaysModeTitleFormat = "MMMM,yyyy"
FpSpread1.ActiveSheetView.Columns(1).CellType = dateCalendarCellType
Dim dateTimeCellType As FarPoint.Web.Spread.DateTimeCellType = New FarPoint.Web.Spread.DateTimeCellType
FpSpread1.ActiveSheetView.Columns(2).CellType = dateTimeCellType
' Buttonの設定
Button1.OnClientClick = "TestA();return false;"
Button1.UseSubmitBehavior = False
' Buttonの設定
Button2.OnClientClick = "TestB();return false;"
Button2.UseSubmitBehavior = False
End Sub
------------------------------------
クライアント側スクリプト
------------------------------------
function TestA() {
var spreadA = document.getElementById("FpSpread1");
spreadA.Insert();
}
function TestB() {
var spreadA = document.getElementById("FpSpread1");
spreadA.UpdatePostbackData();
spreadA.Update();
}
------------------------------------
TestAClass.vb
------------------------------------
Imports Microsoft.VisualBasic
Imports System
Imports System.Web
Imports System.Data
Imports System.ComponentModel
Imports System.Linq
Imports System.Data.Linq
Public Class DataClass
Property ID As Integer
Property A1 As Date
Property A2 As String
End Class
Public Class TestClass
Private ds As DataSet = New System.Data.DataSet("testA")
Private filePath As String = HttpContext.Current.Server.MapPath("~/App_Data/test.xml")
Public Sub New()
ds.ReadXml(filePath, Data.XmlReadMode.ReadSchema)
End Sub
Public Function GetTest() As DataSet
Return ds
End Function
Public Function GetTest2() As IQueryable
Dim query = From row In ds.Tables("testA").AsEnumerable()
Select New DataClass With {
.ID = row.Field(Of Integer)("ID"),
.A1 = row.Field(Of Date)("A1"),
.A2 = row.Field(Of Date)("A2")
}
Return query.AsQueryable()
End Function
Public Sub DeleteTest(ByVal ID As Integer)
Dim workRow As DataRow = ds.Tables(0).Rows.Find(ID)
workRow.BeginEdit()
workRow.Delete()
workRow.EndEdit()
ds.WriteXml(filePath, Data.XmlWriteMode.WriteSchema)
End Sub
Public Sub UpdateTest(ByVal hoge As DataClass)
End Sub
Public Sub InsertTest(ByVal data1 As Data11002Class)
System.Diagnostics.Debug.WriteLine(data1.ID)
System.Diagnostics.Debug.WriteLine(data1.A1)
System.Diagnostics.Debug.WriteLine(data1.A2)
End SubEnd Class
------------------------------------
test.xml
------------------------------------
<?xml version="1.0" standalone="yes"?>
<dsTestA>
<xs:schema id="dsTestA" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="dsTestA" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="TestA">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" />
<xs:element name="A1" type="xs:date" />
<xs:element name="A2" type="xs:date" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//TestA" />
<xs:field xpath="ID" />
</xs:unique>
</xs:element>
</xs:schema>
<TestA>
<ID>1</ID>
<A1>2014-09-01</A1>
<A2>2010-09-01</A2>
</TestA>
<TestA>
<ID>2</ID>
<A1>2015-11-01</A1>
<A2>2011-11-01</A2>
</TestA>
</dsTestA>
【再現手順】
1.新規WebフォームにSPREAD、Button2つ、ObjectDataSourceを配置します
2.Webフォームに下記の再現コードを貼り付けます
3.ObjectDataSource用のビジネスオブジェクトとなるTestAClass.vbファイルを用意します
4.TestAClass.vbに下記のコード(TestAClass.vb)を張り付け、プロジェクトに追加します
5.TestAClass.vb のTestAClassをObjectDataSourceのビジネスオブジェクトとして設定します
6.TestAClassが参照するxml、test.xmlを用意しプロジェクトに追加します
7.test.xmlに下記の内容(test.xml)を張り付け、プロジェクトを起動します
8.2行目を選択しButton1(行の挿入)を押下します
9.挿入された2行目に左から"3"、"2012/08/01"、"2012/08/01"を入力します
10.既存の3行目の2列目、3列目を"2015/12/01"、"2015/12/01"に変更します
11.Button2(Updateの実行)を押下します
-- IntertTestメソッドの2列目の値が「手順10」で更新された値になります
【再現コード】
------------------------------------
Webフォームクラス
------------------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then Return
' FpSpread1の設定
FpSpread1.ActiveSheetView.AutoGenerateColumns = False
FpSpread1.ActiveSheetView.RowCount = 0
FpSpread1.ActiveSheetView.ColumnCount = 3
FpSpread1.ActiveSheetView.Columns(0).DataField = "ID"
FpSpread1.ActiveSheetView.Columns(1).DataField = "A1"
FpSpread1.ActiveSheetView.Columns(2).DataField = "A2"
FpSpread1.DataSourceID = "ObjectDataSource1"
Dim ajaxComboBox As FarPoint.Web.Spread.Extender.AjaxComboBoxCellType = New FarPoint.Web.Spread.Extender.AjaxComboBoxCellType()
ajaxComboBox.DropDownStyle = AjaxControlToolkit.ComboBoxStyle.DropDownList
ajaxComboBox.AutoCompleteMode = AjaxControlToolkit.ComboBoxAutoCompleteMode.SuggestAppend
ajaxComboBox.Items.Add("1")
ajaxComboBox.Items.Add("2")
ajaxComboBox.Items.Add("3")
FpSpread1.ActiveSheetView.Columns(0).CellType = ajaxComboBox
Dim dateCalendarCellType As FarPoint.Web.Spread.Extender.DateCalendarCellType = New FarPoint.Web.Spread.Extender.DateCalendarCellType()
dateCalendarCellType.DateFormat = "yyyy/MM/dd"
dateCalendarCellType.ShowEditor = True
dateCalendarCellType.TodaysDateFormat = "yyyy/MM/dd"
dateCalendarCellType.DaysModeTitleFormat = "MMMM,yyyy"
FpSpread1.ActiveSheetView.Columns(1).CellType = dateCalendarCellType
Dim dateTimeCellType As FarPoint.Web.Spread.DateTimeCellType = New FarPoint.Web.Spread.DateTimeCellType
FpSpread1.ActiveSheetView.Columns(2).CellType = dateTimeCellType
' Buttonの設定
Button1.OnClientClick = "TestA();return false;"
Button1.UseSubmitBehavior = False
' Buttonの設定
Button2.OnClientClick = "TestB();return false;"
Button2.UseSubmitBehavior = False
End Sub
------------------------------------
クライアント側スクリプト
------------------------------------
function TestA() {
var spreadA = document.getElementById("FpSpread1");
spreadA.Insert();
}
function TestB() {
var spreadA = document.getElementById("FpSpread1");
spreadA.UpdatePostbackData();
spreadA.Update();
}
------------------------------------
TestAClass.vb
------------------------------------
Imports Microsoft.VisualBasic
Imports System
Imports System.Web
Imports System.Data
Imports System.ComponentModel
Imports System.Linq
Imports System.Data.Linq
Public Class DataClass
Property ID As Integer
Property A1 As Date
Property A2 As String
End Class
Public Class TestClass
Private ds As DataSet = New System.Data.DataSet("testA")
Private filePath As String = HttpContext.Current.Server.MapPath("~/App_Data/test.xml")
Public Sub New()
ds.ReadXml(filePath, Data.XmlReadMode.ReadSchema)
End Sub
Public Function GetTest() As DataSet
Return ds
End Function
Public Function GetTest2() As IQueryable
Dim query = From row In ds.Tables("testA").AsEnumerable()
Select New DataClass With {
.ID = row.Field(Of Integer)("ID"),
.A1 = row.Field(Of Date)("A1"),
.A2 = row.Field(Of Date)("A2")
}
Return query.AsQueryable()
End Function
Public Sub DeleteTest(ByVal ID As Integer)
Dim workRow As DataRow = ds.Tables(0).Rows.Find(ID)
workRow.BeginEdit()
workRow.Delete()
workRow.EndEdit()
ds.WriteXml(filePath, Data.XmlWriteMode.WriteSchema)
End Sub
Public Sub UpdateTest(ByVal hoge As DataClass)
End Sub
Public Sub InsertTest(ByVal data1 As Data11002Class)
System.Diagnostics.Debug.WriteLine(data1.ID)
System.Diagnostics.Debug.WriteLine(data1.A1)
System.Diagnostics.Debug.WriteLine(data1.A2)
End SubEnd Class
------------------------------------
test.xml
------------------------------------
<?xml version="1.0" standalone="yes"?>
<dsTestA>
<xs:schema id="dsTestA" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="dsTestA" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="TestA">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" />
<xs:element name="A1" type="xs:date" />
<xs:element name="A2" type="xs:date" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//TestA" />
<xs:field xpath="ID" />
</xs:unique>
</xs:element>
</xs:schema>
<TestA>
<ID>1</ID>
<A1>2014-09-01</A1>
<A2>2010-09-01</A2>
</TestA>
<TestA>
<ID>2</ID>
<A1>2015-11-01</A1>
<A2>2011-11-01</A2>
</TestA>
</dsTestA>
回避方法
Service Pack 1(v8.0.4001.2010)で修正済み。