找回密码
 立即注册

QQ登录

只需一步,快速开始

chcchb
论坛元老   /  发表于:2012-1-12 10:54  /   查看:10356  /  回复:13
1.详细页面时,根据读取的数据来判断当前的radio是否为选中
2.如果一开始为未选中,选中后后台怎么判断?需不需要在页面用js给他更新下值

13 个回复

倒序浏览
chcchb
论坛元老   /  发表于:2012-1-12 11:08:00
沙发
给对应的radio设置过true/false 后就被选中
有没有在false时不为选中啊
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-1-12 12:04:00
板凳

回复 1# chcchb 的帖子

chcchb  你好,
测试环境:vs 2010 + Spread for ASP.NET 5.0
1.初始化类型为 RadioButtonListCellType 单元格值,可以使用 读取的数据的值 设置该单元格的 Value 进行初始化。测试代码:

  1. FarPoint.Web.Spread.RadioButtonListCellType rbl = new FarPoint.Web.Spread.RadioButtonListCellType();
  2.             FarPoint.Web.Spread.ListItem[] items = new FarPoint.Web.Spread.ListItem[2];
  3.             FarPoint.Web.Spread.ListItem item = new FarPoint.Web.Spread.ListItem();
  4.             item.Text = "A";
  5.             item.Value = "1";
  6.             items[0] = item;
  7.             item = new FarPoint.Web.Spread.ListItem();
  8.             item.Text = "B";
  9.             item.Value = "2";
  10.             items[1] = item;
  11.             rbl.ListItems = items;
  12.             FpSpread1.ActiveSheetView.Cells[0, 0].CellType = rbl;
  13.             FpSpread1.ActiveSheetView.Cells[0, 0].Value = 1;
复制代码
2.可以设置 RadioButtonListCellType  的 OnCilentClick 属性去挂前台方法,在该方法中 Post 到后台 UpdateCommand 事件中,测试代码:
前台:
  1.   <script type="text/javascript">
  2.         function selectchange() {
  3.                 var spread = this.document.getElementById("FpSpread1");
  4.                 spread.UpdatePostbackData();
  5.                 spread.CallBack("Update");
  6.         }
  7.     </script>
复制代码
后台:

  1.         protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.             FarPoint.Web.Spread.RadioButtonListCellType rbl = new FarPoint.Web.Spread.RadioButtonListCellType();
  4.            //这里调用前台方法
  5.             rbl.OnClientClick = "selectchange();return false";
  6.             FarPoint.Web.Spread.ListItem[] items = new FarPoint.Web.Spread.ListItem[2];
  7.             FarPoint.Web.Spread.ListItem item = new FarPoint.Web.Spread.ListItem();
  8.             item.Text = "A";
  9.             item.Value = "1";
  10.             items[0] = item;
  11.             item = new FarPoint.Web.Spread.ListItem();
  12.             item.Text = "B";
  13.             item.Value = "2";
  14.             items[1] = item;
  15.             rbl.ListItems = items;
  16.             FpSpread1.ActiveSheetView.Cells[0, 0].CellType = rbl;
  17.             FpSpread1.ActiveSheetView.Cells[0, 0].Value = 1;

  18.             FarPoint.Web.Spread.CheckBoxCellType check = new FarPoint.Web.Spread.CheckBoxCellType();
  19.             check.OnClientClick = "selectchange()";
  20.             FpSpread1.Sheets[0].Cells[1, 1].CellType = check;

  21.         }

  22.         protected void FpSpread1_UpdateCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
  23.         {

  24.         }
复制代码
回复 使用道具 举报
chcchb
论坛元老   /  发表于:2012-1-12 12:45:00
地板
  1. FpSpread1.ActiveSheetView.Cells[0, 0].Value = 1;
复制代码
这句话设置radio为选中的吗?
回复 使用道具 举报
chcchb
论坛元老   /  发表于:2012-1-12 13:12:00
5#
项目里只用到一列radio, 所以选中后就不能取消选中状态,除非是重新载入

能不能在操作完后,点击保存时,在后台遍历下那几行被选中,那几行不被选中?
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-1-12 13:18:00
6#

回复 4# chcchb 的帖子

是的,这句是根据 ListItems 中设置的 value 值给单元格赋值,从而控制 RadioButton 的选择状态。
回复 使用道具 举报
chcchb
论坛元老   /  发表于:2012-1-12 13:34:00
7#
那如果ListItems 里面为空,怎么设置呢
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-1-12 13:51:00
8#

回复 7# chcchb 的帖子

chcchb  你好,
1.关于 5# 第一个问题,RadioButtonListCellType 目前不支持该功能,如果只有一列 RadioButton 的话,是否可以考虑使用 CheckBoxCellType 呢?
2.关于 5# 第二个问题,可以在点击 Update 按钮后在 Update 事件中通过 for 循环遍历该列,进而做出判断。
3.关于 7# 的问题,我理解这个 case 为使用 Spread 读取数据,有一列的单元格类型为 RadioButtonListCellType,不知道我理解的是否正确呢?
   那么,这时你可以将该列数据源中对应的数据值,设置为 RadioButtonListCellType 的 Items 值或者 Values 值。
回复 使用道具 举报
chcchb
论坛元老   /  发表于:2012-1-12 15:09:00
9#
4#的问题呢?
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-1-12 15:16:00
10#

回复 9# chcchb 的帖子

chcchb  你好,4# 问题在 6# 中有回复,请问你的问题解决了吗?
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部