之前的方法有些缺陷,可以结合ButtonCellType.OnClientClick和ButtonCommand事件:- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- ButtonCellType bc = new ButtonCellType();
- bc.OnClientClick = "btnClick()";
- this.FpSpread1.ActiveSheetView.Columns[4].CellType = bc;
- }
- }
复制代码- <script language="javascript" type="text/javascript">
- function btnClick() {
- var ss = FpSpread("FpSpread1");
- ss.CallBack("LockColumn,1");
- return false;
- }
- </script>
复制代码- protected void FpSpread1_ButtonCommand(object sender, SpreadCommandEventArgs e)
- {
- if (e.CommandName.Equals("LockColumn"))
- {
- FpSpread1.ActiveSheetView.Columns[4].Locked = (((Point)e.CommandArgument).X)==1?true:false;
- }
- }
复制代码 不过,还有两个小问题需要处理:
1、点击【查看详情】之后是重新打开一个页面吗?
2、什么时机将Button设置为可用呢? |