回复 3楼一萧一剑的帖子
问题1、2后台代码:
- protected override void Render(HtmlTextWriter writer)
- {
- Table cmd = FpSpread1.FindControl("cmdTable") as Table;
- //自定义按钮调用后台事件
- TableCell cell1 = new TableCell();
- Button btn1 = new Button();
- btn1.Text = "save";
- btn1.Attributes.Add("onclick", "SaveButtonClick()");
- cell1.Controls.Add(btn1);
- cmd.Rows[0].Cells.Add(cell1);
- //改变背景色
- Table rheader = this.FpSpread1.FindControl("rh") as Table;
- if (rheader!=null)
- {
- int rowcount = rheader.Rows.Count;
- for (int i = 0; i < rowcount; i++)
- {
- rheader.Rows[i].Cells[0].Attributes.Add("onclick", "ChangeRowBC()");
- }
- }
- Table viewport = this.FpSpread1.FindControl("viewport") as Table;
- if (viewport != null)
- {
- int rowcount = viewport.Rows.Count;
- int colcount = viewport.Rows[0].Cells.Count;
- for (int i = 0; i < rowcount; i++)
- {
- for (int j = 0; j < colcount; j++)
- {
- viewport.Rows[i].Cells[j].Attributes.Add("onclick", "ChangeRowBC()");
- }
- }
- }
- base.Render(writer);
- }
- protected void FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
- {
- if (e.CommandName=="btnSave")
- {
- }
- else if(e.CommandName=="btnChange")
- {
- int row = this.FpSpread1.ActiveSheetView.ActiveRow;
- this.FpSpread1.ActiveSheetView.Rows[row].BackColor = Color.Red;
- }
- }
复制代码
前台代码:
- <script type="text/javascript">
- function SaveButtonClick() {
- if (confirm("您真的需要保存吗")) {
- var spread = this.document.getElementById("FpSpread1");
- spread.CallBack("btnsave");
- }
- }
- function ChangeRowBC() {
- var spread = this.document.getElementById("FpSpread1");
- spread.CallBack("btnChange");
- }
-
- </script>
复制代码
问题3,代码如下:
- this.FpSpread1.EditModePermanent = true;
复制代码
为了给你提供更优质的服务,请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢
|