回复 4楼houdawei的帖子
实现方法如下:
后台代码:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack)
- {
- return;
- }
- DataTable dt = new DataTable();
- dt.Columns.Add("col1", typeof(string));
- dt.Rows.Add("辽宁");
- dt.Rows.Add("吉林");
- dt.Rows.Add("河北");
- this.FpSpread1.ActiveSheetView.DataSource = dt;
- }
- protected override void Render(HtmlTextWriter writer)
- {
- Table tb = this.FpSpread1.FindControl("viewport") as Table;
- for (int i = 0; i < tb.Rows.Count; i++)
- {
- tb.Rows[i].Cells[0].Attributes.Add("onclick","test()");
- }
- base.Render(writer);
- }
- protected void FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
- {
- }
复制代码
前台代码:
- <script type="text/javascript">
- function test() {
- var spread = this.document.getElementById("FpSpread1");
- var col = FpSpread1.GetActiveCol();
- var row= FpSpread1.GetActiveRow();
- var scell = FpSpread1.GetValue(row, col);
- spread.CallBack("Button"+scell, true);
- }
- </script>
复制代码
请你尝试后反馈结果,有问题欢迎继续讨论。 |