チェックボックス型セルで値の設定が不正になる

文書番号 : 39102     文書種別 : 不具合     登録日 : 2015/09/15     最終更新日 : 2015/10/08
文書を印刷する
対象製品
SPREAD for ASP.NET 8.0J
状況
修正済み
詳細
SPREADの更新後、所定の操作を行うことによってチェックボックス型セルで値の設定が不正になる場合があります。

【再現手順】
1.新規WebフォームにSPREADひとつを配置する
2.Webフォームに下記の再現コードを貼り付け、Web フォームを起動する
3.チェックボックス型セルのチェックボックス部分をクリックしてチェック状態にする。
4.SPREADの更新ボタンをクリックする。
5.チェックボックス型セルのチェックボックス部分をクリックしてチェック状態を解除する。
6.チェックボックス型セルのチェックボックス以外の部分をクリックする。
7.SPREADの更新ボタンをクリックする。
--- チェックボックス型セルがチェック状態になっている。

【再現コード】
------------------------------------
Webフォームクラス
------------------------------------
Imports FarPoint.Web.Spread
Public Class WebForm1
  Inherits System.Web.UI.Page

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Page.IsPostBack Then
      Return
    End If

    Dim cCell As New FarPoint.Web.Spread.CheckBoxCellType()
    FpSpread1.ActiveSheetView.Columns(0).CellType = cCell
  End Sub

End Class
回避方法
Service Pack 2(v8.0.4002.2010)で修正済み。
Service Pack 2(v8.0.4002.2010)より前のバージョンでは次の回避方法が有効です。
------------------------------------------

下記のように、MouseUpイベントの動作をオーバーライドしたカスタムセルを使用することで現象の回避が可能です。

【再現コードへの回避方法適用例】
------------------------------------
Webフォームクラス
------------------------------------
Imports FarPoint.Web.Spread

Public Class WebForm1
  Inherits System.Web.UI.Page

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Page.IsPostBack Then
      Return
    End If

    'Dim cCell As New FarPoint.Web.Spread.CheckBoxCellType()
    Dim cCell As New CustomCheckbox()
    FpSpread1.ActiveSheetView.Columns(0).CellType = cCell
  End Sub

End Class

<Serializable> _
Public Class CustomCheckbox
  Inherits CheckBoxCellType
  Public Overrides Function PaintCell(id As String, parent As TableCell, style As Appearance, margin As Inset, value As Object, upperLevel As Boolean) As Control
    Dim ctrl As Control = MyBase.PaintCell(id, parent, style, margin, value, upperLevel)

    parent.Attributes.Add("onmouseup", "CustomCheckbox_mouseup(event)")

    Return ctrl
  End Function
End Class

------------------------------------
クライアント側スクリプト
------------------------------------
<script type="text/javascript">
  // MouseUpの動作をオーバーライド
  function CustomCheckbox_mouseup(event) {
    var event = event || window.event;
    var spread = document.getElementById("FpSpread1");
    if (spread.isEditing && spread.isEditing()) {
      if (event.type == "mouseup" && (event.target || event.srcElement).tagName != "INPUT") {
        try {
          if (event.stopPropagation)
            event.stopPropagation();
          event.cancelBubble = true;
          document.releaseCapture();

        } catch (e) { }
      }
    }
  };
</script>