找回密码
 立即注册

QQ登录

只需一步,快速开始

yycf

注册会员

10

主题

37

帖子

101

积分

注册会员

积分
101

活字格认证元老葡萄

yycf
注册会员   /  发表于:2016-3-24 09:07  /   查看:4175  /  回复:4
1)在单元格文本框上输入内容,有可能是数字型、日期型,有没有办法可以提示用户必须输入有效格式数据,或者输入时对数据格式进行检查;

2)单元格中可以选择多种组件,比如:文本框、下拉框、复选框,我想问一下如果是下拉框,除了可以选择内容,
是否可以进行编辑,下拉框中没有的内容,可以由用户自行输入;

4 个回复

倒序浏览
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-3-24 10:23:30
沙发
第一个问题你可以参考文档中的 Using Validation Controls 章节,里面有详细的步骤使用前端验证,你可以直接把下面的代码复制使用。

  1. if (IsPostBack) return;
  2.             FpSpread1.Sheets[0].RowCount = 10;
  3.             FpSpread1.Sheets[0].ColumnCount = 7;
  4.             // RequiredFieldValidator, from code
  5.             FarPoint.Web.Spread.TextCellType txt1 = new FarPoint.Web.Spread.TextCellType();
  6.             RequiredFieldValidator rfv = new RequiredFieldValidator();
  7.             rfv.ErrorMessage = "RequiredFieldValidator, from code: value required!";
  8.             txt1.Validators.Add(rfv);
  9.             FpSpread1.ActiveSheetView.Cells[0, 0].Text = "RequiredFieldValidator, from code";
  10.             FpSpread1.ActiveSheetView.Cells[0, 1].CellType = txt1;

  11.             // CompareValidator, from code
  12.             FarPoint.Web.Spread.TextCellType txt4 = new FarPoint.Web.Spread.TextCellType();
  13.             CompareValidator cv = new CompareValidator();
  14.             cv.ErrorMessage = "CompareValidator, from toolbox: password does not match! Enter "Spread"";
  15.             cv.ValueToCompare = "Spread";
  16.             txt4.Validators.Add(cv);
  17.             FpSpread1.ActiveSheetView.Cells[3, 0].Text = "CompareValidator, from code";
  18.             FpSpread1.ActiveSheetView.Cells[3, 1].CellType = txt4;
复制代码

回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-3-24 10:41:09
板凳
您可以使用FarPoint.Web.Spread.Extender中的AjaxComboBoxCellType,具体使用方法可以看下文档AutoCompleteMode Property这个章节以及AjaxComboBoxCellType 的内容。一下代码可以直接运行。需要引用FarPoint.Web.Spread.Extender.dll和AjaxControlToolkit.dll(可以在vs中使用nuget直接安装)在aspx页面添加

  1.             <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
复制代码

cs代码
  1.             string[] cbstr;
  2.             cbstr = new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun" };
  3.             FarPoint.Web.Spread.ComboBoxCellType cmbbx = new FarPoint.Web.Spread.ComboBoxCellType(cbstr);
  4.             FpSpread1.ActiveSheetView.Cells[1, 1].CellType = cmbbx;

  5.             FarPoint.Web.Spread.Extender.AjaxComboBoxCellType combo = new FarPoint.Web.Spread.Extender.AjaxComboBoxCellType();
  6.             combo.BackColor = System.Drawing.Color.Aquamarine;
  7.             combo.AutoCompleteMode = AjaxControlToolkit.ComboBoxAutoCompleteMode.Append;
  8.             combo.ShowEditor = true;
  9.             combo.DropDownStyle = AjaxControlToolkit.ComboBoxStyle.DropDown;
  10.             combo.ItemInsertLocation = AjaxControlToolkit.ComboBoxItemInsertLocation.OrdinalText;
  11.             combo.Items.Add("test");
  12.             combo.Items.Add("second");
  13.             combo.CaseSensitive = true;
  14.             combo.AutoPostBack = true;
  15.             FpSpread1.Sheets[0].Cells[0, 0].CellType = combo;
复制代码



回复 使用道具 举报
yycf
注册会员   /  发表于:2016-3-25 16:52:45
地板
第一个问题已经基本解决解决,谢谢
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-3-25 19:09:56
5#
关于AjaxComboBoxCellType  可以在文档中看下具体使用。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部