Excelフィルタリング実行後にASP.NETのICallbackEventHandlerでコールバックできない
対象製品
SPREAD for ASP.NET 8.0J
状況
修正済み
詳細
Excelフィルタリング実行後にASP.NETのICallbackEventHandlerでコールバック出来なくなります。
【再現コード】
------------------------------------
Webフォームクラス
------------------------------------
Public Class WebForm1
Inherits System.Web.UI.Page
Implements System.Web.UI.ICallbackEventHandler
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack Then Return
'コールバックイベントの登録
Dim cbReference As String = Page.ClientScript.GetCallbackEventReference(Me, "arg", "receiveServerData", "context", "clientErrorCallback", False)
Dim callbackScript As String = "function CallServer(arg, context, clientError,isAsync) { " & cbReference & "} ;"
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "CallServer", callbackScript, True)
' データの設定
For i As Integer = 0 To FpSpread1.ActiveSheetView.RowCount - 1
FpSpread1.ActiveSheetView.SetValue(i, 0, i)
Next
' フィルタの設定
FpSpread1.ActiveSheetView.AutoFilterMode = FarPoint.Web.Spread.AutoFilterMode.Enhanced
Dim sf1 As New FarPoint.Web.Spread.HideRowFilter(FpSpread1.ActiveSheetView)
sf1.AddColumn(New FarPoint.Web.Spread.FilterColumnDefinition(0))
FpSpread1.ActiveSheetView.RowFilter = sf1
End Sub
Public Function GetCallbackResult() As String Implements System.Web.UI.ICallbackEventHandler.GetCallbackResult
'コールバックレスポンスの設定
Dim result As String
result = DateTime.Now.ToLongTimeString
Return result
End Function
Public Sub RaiseCallbackEvent(ByVal eventArgument As String) Implements System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent
'コールバックリクエストの取得
End Sub
End Class
------------------------------------
aspxファイル
------------------------------------
<FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="#A0A0A0" BorderStyle="Solid" BorderWidth="1px" Height="200" Width="400">
<commandbar backcolor="#F6F6F6" buttonfacecolor="Control" buttonhighlightcolor="ControlLightLight" buttonshadowcolor="ControlDark">
</commandbar>
<sheets>
<FarPoint:SheetView SheetName="Sheet1">
</FarPoint:SheetView>
</sheets>
</FarPoint:FpSpread>
<input id="Button1" style="position: static" type="button" value="page.callback" onclick="doCallBack();"/>
<span id="result" style="background-color:beige">result:</span>
------------------------------------
クライアント側スクリプト
------------------------------------
function doCallBack() {
CallServer("", "", clientErrorCallback, false);
}
function clientErrorCallback(arg, context) {
alert(arg);
}
function receiveServerData(arg, context) {
result.innerText = arg;
}
【再現手順】
1.プロジェクトを起動します
2.標準のボタンをクリックします
-- 現在の時刻が表示されます
3.Excelフィルタのドロップダウンを表示し"1"のみチェックします
-- フィルタリングが実行されます
4.標準のボタンをクリックします
-- 現在の時刻が表示されません
【再現コード】
------------------------------------
Webフォームクラス
------------------------------------
Public Class WebForm1
Inherits System.Web.UI.Page
Implements System.Web.UI.ICallbackEventHandler
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack Then Return
'コールバックイベントの登録
Dim cbReference As String = Page.ClientScript.GetCallbackEventReference(Me, "arg", "receiveServerData", "context", "clientErrorCallback", False)
Dim callbackScript As String = "function CallServer(arg, context, clientError,isAsync) { " & cbReference & "} ;"
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "CallServer", callbackScript, True)
' データの設定
For i As Integer = 0 To FpSpread1.ActiveSheetView.RowCount - 1
FpSpread1.ActiveSheetView.SetValue(i, 0, i)
Next
' フィルタの設定
FpSpread1.ActiveSheetView.AutoFilterMode = FarPoint.Web.Spread.AutoFilterMode.Enhanced
Dim sf1 As New FarPoint.Web.Spread.HideRowFilter(FpSpread1.ActiveSheetView)
sf1.AddColumn(New FarPoint.Web.Spread.FilterColumnDefinition(0))
FpSpread1.ActiveSheetView.RowFilter = sf1
End Sub
Public Function GetCallbackResult() As String Implements System.Web.UI.ICallbackEventHandler.GetCallbackResult
'コールバックレスポンスの設定
Dim result As String
result = DateTime.Now.ToLongTimeString
Return result
End Function
Public Sub RaiseCallbackEvent(ByVal eventArgument As String) Implements System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent
'コールバックリクエストの取得
End Sub
End Class
------------------------------------
aspxファイル
------------------------------------
<FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="#A0A0A0" BorderStyle="Solid" BorderWidth="1px" Height="200" Width="400">
<commandbar backcolor="#F6F6F6" buttonfacecolor="Control" buttonhighlightcolor="ControlLightLight" buttonshadowcolor="ControlDark">
</commandbar>
<sheets>
<FarPoint:SheetView SheetName="Sheet1">
</FarPoint:SheetView>
</sheets>
</FarPoint:FpSpread>
<input id="Button1" style="position: static" type="button" value="page.callback" onclick="doCallBack();"/>
<span id="result" style="background-color:beige">result:</span>
------------------------------------
クライアント側スクリプト
------------------------------------
function doCallBack() {
CallServer("", "", clientErrorCallback, false);
}
function clientErrorCallback(arg, context) {
alert(arg);
}
function receiveServerData(arg, context) {
result.innerText = arg;
}
【再現手順】
1.プロジェクトを起動します
2.標準のボタンをクリックします
-- 現在の時刻が表示されます
3.Excelフィルタのドロップダウンを表示し"1"のみチェックします
-- フィルタリングが実行されます
4.標準のボタンをクリックします
-- 現在の時刻が表示されません
回避方法
Service Pack 3(v8.0.4004.2010)で修正済み。
Service Pack 3(v8.0.4004.2010)より前のバージョンでは次の回避方法が有効です。
------------------------------------------
クライアント側からの送信データが正しくなるよう明示的にスクリプトを定義します。
--------------------------------------------
クライアントサイド
--------------------------------------------
// 回避策:開始
window.onload = function () {
var ss = document.getElementById("FpSpread1");
if (ss != null) {
var __oldtheFormPostData = __theFormPostData;
ss.addEventListener("CallBackStart", function () {
if (typeof (__theFormPostData) != "undefined") {
__theFormPostData = "";
__theFormPostCollection = [];
}
}, false);
ss.addEventListener("CallBackStopped", function () {
__theFormPostData = __oldtheFormPostData;
}, false);
}
}
Service Pack 3(v8.0.4004.2010)より前のバージョンでは次の回避方法が有効です。
------------------------------------------
クライアント側からの送信データが正しくなるよう明示的にスクリプトを定義します。
--------------------------------------------
クライアントサイド
--------------------------------------------
// 回避策:開始
window.onload = function () {
var ss = document.getElementById("FpSpread1");
if (ss != null) {
var __oldtheFormPostData = __theFormPostData;
ss.addEventListener("CallBackStart", function () {
if (typeof (__theFormPostData) != "undefined") {
__theFormPostData = "";
__theFormPostCollection = [];
}
}, false);
ss.addEventListener("CallBackStopped", function () {
__theFormPostData = __oldtheFormPostData;
}, false);
}
}