回复 5楼simonshen的帖子
方法就是2楼中提到的方法,在Click事件中判断该列是不是还有其它Radio被选中,如果有将其设置为不选中状态:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack)
- return;
- FarPoint.Web.Spread.RadioButtonListCellType rbl = new FarPoint.Web.Spread.RadioButtonListCellType();
- rbl.OnClientClick = "Column1ValueChanged()";
- FarPoint.Web.Spread.ListItem[] items = new FarPoint.Web.Spread.ListItem[2];
- FarPoint.Web.Spread.ListItem item = new FarPoint.Web.Spread.ListItem();
- item.Text = "A";
- item.Value = "1";
- items[0] = item;
- item = new FarPoint.Web.Spread.ListItem();
- item.Text = "B";
- item.Value = "2";
- items[1] = item;
- rbl.ListItems = items;
- FpSpread1.ActiveSheetView.Columns[0].CellType = rbl;
- //选择按钮 A
- FpSpread1.ActiveSheetView.Cells[0, 0].Value = 1;
- //选择按钮 B
- FpSpread1.ActiveSheetView.Cells[1, 0].Value = 0;
- //设置非 item.value 值即为不选择
- FpSpread1.ActiveSheetView.Cells[2, 0].Value = 0;
- }
复制代码
- <script language="javascript" type="text/javascript">
- function Column1ValueChanged(event) {
- var spread1 = document.getElementById("<%=FpSpread1.ClientID %>");
- var rc = spread1.GetRowCount();
- var ac = spread1.ActiveRow;
- for (var r = 0; r < rc; r++) {
- var v = spread1.GetValue(r,0);
- if (r != ac && v != null) {
- spread1.SetValue(r, 0,null);
- }
- }
- }
- </script>
复制代码 |