原創|使用教程|編輯:龔雪|2015-06-01 10:35:24.000|閱讀 548 次
概述:Spread for ASP.NET 表格控件 在前臺提供了 Callback 方法用于調用后臺 Command 事件,通過這個事件我們就可以根據前臺的用戶行為調用后臺的 Spread 豐富的接口去操作 Spread。論壇中也有很多用戶詢問,因此在本篇文章中記錄下使用方法。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Spread for ASP.NET 表格控件 在前臺提供了 Callback 方法用于調用后臺 Command 事件,通過這個事件我們就可以根據前臺的用戶行為調用后臺的 Spread 豐富的接口去操作 Spread。論壇中也有很多用戶詢問,因此在本篇文章中記錄下使用方法。
本篇文章中我們以捕獲前臺用戶鼠標單擊事件為例進行功能描述。
1.后臺添加Cell的 onclick 事件:
Spread 表格控件渲染到前臺后是以 HTML Table 進行展示的。
后臺代碼:
protected override void Render(HtmlTextWriter writer) { Table viewPort = this.FpSpread1.FindControl("viewport") as Table; viewPort.Attributes.Add("onclick", "clickOnSpread()"); base.Render(writer); }
前臺代碼:
<script type="text/javascript"> function clickOnSpread() { } </script>
2.前臺獲取 Spread DOM 節點,并且調用 CallBack 方法:
<script type="text/javascript"> function clickOnSpread() { var spread = this.document.getElementById("FpSpread1"); //獲取點擊行列信息 var activeRow = spread.GetActiveRow(); var activeCol = spread.GetActiveCol(); //CallBack到后臺 spread.CallBack("前臺點擊事件"+"Row:"+activeRow+"Col:"+activeCol,true); } </script>
3.添加 ButtonCommand 事件,在 CallBack 事件中獲取單元格信息。
protected void FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e) { //獲取當前操作的Spread,從而可以獲取當前 Spread 的任何信息 FarPoint.Web.Spread.FpSpread currentSpread = (FarPoint.Web.Spread.FpSpread)(sender); //取得事件名稱 string commandName = e.CommandName; //取得當前操作表單 FarPoint.Web.Spread.SheetView currentSheetView = e.SheetView; }
以上即為添加前臺操作后臺響應的詳細操作步驟。
Demo 下載:VS2013 + C# + Spread 8.0
下載 Spread 表格控件體驗更多功能,請點擊:
//fc6vip.cn/product/835
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn