找回密码
 立即注册

QQ登录

只需一步,快速开始

一萧一剑

中级会员

30

主题

70

帖子

650

积分

中级会员

积分
650

活字格认证微信认证勋章元老葡萄

一萧一剑
中级会员   /  发表于:2015-3-17 15:11  /   查看:6600  /  回复:9
1.)为什么点击单元格断点不进入CellClick事件?它是怎么触发的。
2.)设置了单元格为链接样式,点击单元格跳转到另一个界面的时候参数会显示在地址栏,不安全。
FarPoint.Web.Spread.HyperLinkCellType linkBtn = new FarPoint.Web.Spread.HyperLinkCellType()
linkBtn.NavigateUrl = &quotackPrice.aspx?strNO=2"
可以影藏地址栏参数吗?如果不能问一下怎么在单元格中添加链接按钮,或者单击单元格触发事件,在后台代码中自己写跳转。
技术改变世界

9 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2015-3-17 16:23:00
沙发
回复 1楼一萧一剑的帖子

1.CellClick 事件需要在 SheetView 的 AutoPostBack  属性设置为 true 的时候才启作用。
2.可以使用 buttonCelltype模拟链接,点击会触发后台buttoncommand事件,代码如下:

  1.         protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.             if (IsPostBack)
  4.             {
  5.                 return;
  6.             }

  7.             FarPoint.Web.Spread.ButtonCellType btn = new FarPoint.Web.Spread.ButtonCellType("MyRed");
  8.             btn.ButtonType = FarPoint.Web.Spread.ButtonType.LinkButton;

  9.             this.FpSpread1.ActiveSheetView.Columns[0].CellType = btn;


  10.         }

  11.         protected void FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
  12.         {
  13.             this.Response.Redirect("http://gcdn.gcpowertools.com.cn/showtopic-16192.html");
  14.         }
复制代码


为了给你提供更优质的服务,请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢
回复 使用道具 举报
一萧一剑
中级会员   /  发表于:2015-3-18 08:59:00
板凳
试了一下界面显示和一般单元格没有2样,点击那一列断点也不进入buttoncommand事件,回复好像不能传图片,代码如下:
(另外问一下自适应列宽怎么设置,谢谢)

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
               
                if (!CheckUserAccess("A"))
                {
                  
                }
                InitHeaders();
               
            }


            FarPoint.Web.Spread.ButtonCellType btn = new FarPoint.Web.Spread.ButtonCellType("MyRed");
            btn.ButtonType = FarPoint.Web.Spread.ButtonType.LinkButton;
            this.FpSpreadGV.ActiveSheetView.Columns[3].CellType = btn;

            LoadData();
        }
技术改变世界
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2015-3-18 13:49:00
地板
回复 3楼一萧一剑的帖子

附件是我的测试 Demo ,可以查看下是否满足你的需求:
16192.zip (7.52 KB, 下载次数: 288)
回复 使用道具 举报
一萧一剑
中级会员   /  发表于:2015-3-18 14:36:00
5#
我试了一下自己 的为什么不行,
FpSpreadGV.Sheets[0].Columns[3].DataField = "numIndex";
因为我绑定了数据列,所以显示的时候不是按钮链接样式,点击也不会进入断点,
我想实现的功能是该列数据由后台数据绑定,然后点击链接可获取该列数据然后跳转页面。
技术改变世界
回复 使用道具 举报
一萧一剑
中级会员   /  发表于:2015-3-18 14:49:00
6#
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
               
                if (!CheckUserAccess("A"))
                {
                  
                }
                InitHeaders();
               
            }
           
            FpSpreadGV.ActiveSheetView.DefaultStyle.CellType = new FarPoint.Web.Spread.GeneralCellType() { AllowWrap = false };
            FarPoint.Web.Spread.ButtonCellType btn = new FarPoint.Web.Spread.ButtonCellType("MyRed");
            btn.ButtonType = FarPoint.Web.Spread.ButtonType.LinkButton;
            this.FpSpreadGV.Sheets[0].Columns[3].CellType = btn;


            LoadData();
        }
  
我想通过绑定后给按钮赋值,加载后显示的Text都是相同的为什么,
根据我的理解应该 按钮显示的Text应该不一样才对,
for (int i = 0; i < FpSpreadGV.Rows.Count; i++)
                    {
                        FarPoint.Web.Spread.ButtonCellType btn = FpSpreadGV.ActiveSheetView.Columns[3].CellType as FarPoint.Web.Spread.ButtonCellType;
                        btn.Text = FpSpreadGV.ActiveSheetView.Cells[i, 4].Text;
                   }
技术改变世界
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2015-3-18 17:31:00
7#
回复 6楼一萧一剑的帖子

如果希望每个按钮的数据不同,那么需要给每个按钮独立绑定一个 button 不能在 Column 单位上设置。
回复 使用道具 举报
一萧一剑
中级会员   /  发表于:2015-3-19 08:29:00
8#
“给每个按钮独立绑定一个 button 不能在 Column 单位上设置”,这句话不懂,给按钮绑定button?
是给button赋值吗,为什么遍历赋值后还是只显示同一个值。
要怎么实现列的值由后台数据绑定,列的显示样式是linkbutton,点击linkbutton执行后台代码就可以了?
for (int i = 0; i < FpSpreadGV.Rows.Count; i++)
                    {
                        FarPoint.Web.Spread.ButtonCellType btn = FpSpreadGV.ActiveSheetView.Columns[3].CellType as FarPoint.Web.Spread.ButtonCellType;
                        btn.Text = FpSpreadGV.ActiveSheetView.Cells[i, 4].Text;
                   }
技术改变世界
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2015-3-19 11:56:00
9#
回复 8楼一萧一剑的帖子

抱歉,文字描述有误,给每个单元格绑定单独的button,代码如下:

  1.         protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.             if (IsPostBack)
  4.             {
  5.                 return;
  6.             }

  7.             DataTable dt = new DataTable();
  8.             dt.Columns.Add("col1");
  9.             for (int i = 0; i < 10; i++)
  10.             {
  11.                 dt.Rows.Add(i.ToString());
  12.             }

  13.             this.FpSpread1.DataSource = dt;

  14.             for (int i = 0; i < 10; i++)
  15.             {
  16.                 FarPoint.Web.Spread.ButtonCellType btn = new FarPoint.Web.Spread.ButtonCellType("mybutton"+i.ToString());
  17.                 btn.ButtonType = FarPoint.Web.Spread.ButtonType.LinkButton;
  18.                 btn.Text = "mybutton" + i.ToString();

  19.                 this.FpSpread1.ActiveSheetView.Cells[i, 0].CellType = btn;
  20.             }

  21.         }
复制代码

评分

参与人数 1满意度 +5 收起 理由
一萧一剑 + 5 嗯谢谢

查看全部评分

回复 使用道具 举报
iceman
社区贡献组   /  发表于:2015-3-26 16:43:00
10#
回复 8楼一萧一剑的帖子

为了给你提供更优质的服务,请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢   
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部