找回密码
 立即注册

QQ登录

只需一步,快速开始

zhu_99031

银牌会员

9

主题

29

帖子

3586

积分

银牌会员

积分
3586

活字格认证

zhu_99031
银牌会员   /  发表于:2012-2-8 10:19  /   查看:6020  /  回复:5
FarPoint.Web.Spread.CheckBoxCellType checkBoxType2 = new FarPoint.Web.Spread.CheckBoxCellType();
                checkBoxType2.OnClientClick = "postback()";

为什么没有OnClientClick 方法   

4.0 不支持吗?

5 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2012-2-8 11:11:00
沙发

回复 1# zhu_99031 的帖子

zhu_99031 你好,
1.CheckBoxCellType OnClientClick  从 Spread for ASP.NET 5.0 中 开始支持。
2.我们可以通过 js 去给 CheckBoxCellType 添加 onclick 事件,我的实现方法如下:
后台:
  1. FarPoint.Web.Spread.CheckBoxCellType check = new FarPoint.Web.Spread.CheckBoxCellType();
  2.                 FpSpread1.Sheets[0].Cells[1, 1].CellType = check;
复制代码

前台:

  1.     <script type="text/javascript">
  2.         window.onload = function () {
  3.         var checkbox = document.getElementById("FpSpread1_1,1");
  4.         checkbox.onclick = function showmsg() {
  5.             alert('Hello!World');
  6.          }
  7.         }
  8.     </script>
复制代码
回复 使用道具 举报
zhu_99031
银牌会员   /  发表于:2012-2-8 12:41:00
板凳

回复 2# iceman 的帖子

FarPoint.Web.Spread.CheckBoxCellType chkTypeHeader = new FarPoint.Web.Spread.CheckBoxCellType();
                chkTypeHeader.Text = &quot;选择&quot;;
                this.FpSpread1.Sheets[0].ColumnHeader.Cells[0, 0].CellType = chkTypeHeader;  

window.onload = function () {
    var checkbox = document.getElementById(&quot;FpSpread1_0,0,ch&quot;);
    checkbox.onclick = function CheckAll() {
        var spread;
        spread = document.getElementById(&quot;FpSpread1&quot;);
        if (this.checked) {
            for (var i = 0; i &lt; spread.GetRowCount(); i++) {
                spread.SetValue(i, 0, &quot;true&quot;, true);
            }
        }
        else {
            for (i = 0; i &lt; spread.GetRowCount(); i++) {
                spread.SetValue(i, 0, &quot;false&quot;, false);
            }
            FpSpread1.UpdatePostbackData();
            FpSpread1.CallBack(&quot;Update&quot;);
        }
    }

我这样写 第一次可以, 第二次就不能全选了   这是为什么?
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-2-9 10:44:00
地板

回复 3# zhu_99031 的帖子

zhu_99031 你好,请尝试以下代码:
后台代码:

  1.         protected override void Render(HtmlTextWriter writer)
  2.         {
  3.                 CheckBox test = (CheckBox)(this.FpSpread1.FindControl("0,0,ch"));
  4.                 test.Attributes.Add("onclick", "check()");
  5.                 base.Render(writer);
  6.         }
复制代码

前台代码:

  1.     <script type="text/javascript">
  2.         function check() {
  3.             var spread;
  4.             spread = document.getElementById("FpSpread1");
  5.             var checkbox1 = document.getElementById("FpSpread1_0,0,ch");
  6.             if (checkbox1.checked) {
  7.                 for (var i = 0; i < spread.GetRowCount(); i++) {
  8.                     spread.SetValue(i, 0, "true", true);
  9.                 }
  10.             }
  11.             else {
  12.                 for (i = 0; i < spread.GetRowCount(); i++) {
  13.                     spread.SetValue(i, 0, "false", false);
  14.                 }
  15.                 FpSpread1.UpdatePostbackData();
  16.                 FpSpread1.CallBack("Update");
  17.             }
  18.             return false;
  19.         }        
  20.     </script>
复制代码
回复 使用道具 举报
zhu_99031
银牌会员   /  发表于:2012-2-10 16:49:00
5#

回复 4# iceman 的帖子

谢谢~~
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-2-13 09:43:00
6#

回复 5# zhu_99031 的帖子

不必客气~
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部