找回密码
 立即注册

QQ登录

只需一步,快速开始

Catsou55

初级会员

6

主题

24

帖子

368

积分

初级会员

积分
368

活字格认证

最新发帖
Catsou55
初级会员   /  发表于:2018-4-25 10:11  /   查看:5334  /  回复:9
本帖最后由 Catsou55 于 2018-4-25 10:26 编辑

整数型单元格的默认可以输入任何字符,为了实现只能输入数字的功能,需要结合InputMan的验证控件GcCharacterTypeValidator。代码如下所示,数字输入功能实现了,可是数值1~999的范围check失效了。麻烦帮看看问题出在哪里。

        Dim intCell As New IntegerCellType
        intCell.MinimumValue = 1
        intCell.MaximumValue = 999

        Dim GcCharacterTypeValidator1 As New GcCharacterTypeValidator
        GcCharacterTypeValidator1.ID = "dataTypeValidator1"
        GcCharacterTypeValidator1.ValidateOnInput = True
        GcCharacterTypeValidator1.CharacterSet = "9"
        GcCharacterTypeValidator1.ValidatorActionID = "GcValidatorAction1"

        Dim valProc As New ValueProcess
        valProc.ValueProcessOption = ValueProcessOption.Restore
        GcValidatorAction1.DefaultActions.Add(valProc)

        intCell.Validators.Add(GcCharacterTypeValidator1)

9 个回复

倒序浏览
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2018-4-25 12:31:06
沙发
建议您直接发可直接运行的Demo,这样处理快很多。
回复 使用道具 举报
Catsou55
初级会员   /  发表于:2018-4-25 13:53:54
板凳
<%@ Page Language="VB" Inherits="System.Web.UI.Page" %>

<%@ Register assembly="GrapeCity.Web.Input.v100, Version=10.0.4000.2012, Culture=neutral, PublicKeyToken=c3bd7c1dccef5128" namespace="GrapeCity.Web.Input.IMValidators" tagprefix="im_validator" %>

<%@ Register assembly="GrapeCity.Web.Input.v100, Version=10.0.4000.2012, Culture=neutral, PublicKeyToken=c3bd7c1dccef5128" namespace="GrapeCity.Web.Input.IMExtenders" tagprefix="im_extenders" %>

<!DOCTYPE html>
<script language="VB" type="text/VB" runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        InitVaSpread1()
    End Sub

    Private Sub InitVaSpread1()
        FpSpread1.EditModeReplace = True
        FpSpread1.ProcessTab = True

        FpSpread1.HorizontalScrollBarPolicy = ScrollBarPolicy.Never
        FpSpread1.VerticalScrollBarPolicy = ScrollBarPolicy.Always

        FpSpread1.ActiveSheetView.DefaultRowHeight = 37

        FpSpread1.ActiveSheetView.RowCount = 4
        FpSpread1.ActiveSheetView.ColumnCount = 2

        FpSpread1.ColumnHeader.Cells(0, 0).Value = "Col1"
        FpSpread1.ColumnHeader.Cells(0, 1).Value = "Col2"

        FpSpread1.ActiveSheetView.Columns(0).Width = 100
        FpSpread1.ActiveSheetView.Columns(1).Width = 100

        FpSpread1.ActiveSheetView.Columns(0).BackColor = Drawing.Color.Yellow
        FpSpread1.ActiveSheetView.Columns(0).CellType = New TextCellType With {.AllowWrap = True}

        Dim intCell As New IntegerCellType
        intCell.MinimumValue = 1
        intCell.MaximumValue = 999

        GcCharacterTypeValidator1.ID = "dataTypeValidator1"
        GcCharacterTypeValidator1.ValidateOnInput = True
        GcCharacterTypeValidator1.CharacterSet = "9"
        GcCharacterTypeValidator1.ValidatorActionID = "GcValidatorAction1"

        Dim valProc As New ValueProcess
        valProc.ValueProcessOption = ValueProcessOption.Restore
        GcValidatorAction1.DefaultActions.Add(valProc)

        intCell.Validators.Add(GcCharacterTypeValidator1)

        FpSpread1.ActiveSheetView.Columns(1).CellType = intCell
    End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    </div>
        <FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="#A0A0A0" BorderStyle="Solid" BorderWidth="1px" Height="200" Width="400">
            <CommandBar BackColor="#F6F6F6" ButtonFaceColor="Control" ButtonHighlightColor="ControlLightLight" ButtonShadowColor="ControlDark">
            </CommandBar>
            <Sheets>
                <FarPoint:SheetView SheetName="Sheet1">
                </FarPoint:SheetView>
            </Sheets>
        </FarPoint:FpSpread>
        <im_validator:GcCharacterTypeValidator ID="GcCharacterTypeValidator1" runat="server" ErrorMessage="GcCharacterTypeValidator" HasLoadFromXml="True"></im_validator:GcCharacterTypeValidator>
        <im_extenders:GcValidatorAction ID="GcValidatorAction1" runat="server"></im_extenders:GcValidatorAction>
    </form>
</body>
</html>
回复 使用道具 举报
Catsou55
初级会员   /  发表于:2018-4-25 13:55:01
地板
下面是全的文件:

<%@ Page Language="VB" Inherits="System.Web.UI.Page" %>

<%@ Register assembly="GrapeCity.Web.Input.v100, Version=10.0.4000.2012, Culture=neutral, PublicKeyToken=c3bd7c1dccef5128" namespace="GrapeCity.Web.Input.IMValidators" tagprefix="im_validator" %>

<%@ Register assembly="GrapeCity.Web.Input.v100, Version=10.0.4000.2012, Culture=neutral, PublicKeyToken=c3bd7c1dccef5128" namespace="GrapeCity.Web.Input.IMExtenders" tagprefix="im_extenders" %>

<!DOCTYPE html>
<script language="VB" type="text/VB" runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        InitVaSpread1()
    End Sub

    Private Sub InitVaSpread1()
        FpSpread1.EditModeReplace = True
        FpSpread1.ProcessTab = True

        FpSpread1.HorizontalScrollBarPolicy = ScrollBarPolicy.Never
        FpSpread1.VerticalScrollBarPolicy = ScrollBarPolicy.Always

        FpSpread1.ActiveSheetView.DefaultRowHeight = 37

        FpSpread1.ActiveSheetView.RowCount = 4
        FpSpread1.ActiveSheetView.ColumnCount = 2

        FpSpread1.ColumnHeader.Cells(0, 0).Value = "Col1"
        FpSpread1.ColumnHeader.Cells(0, 1).Value = "Col2"

        FpSpread1.ActiveSheetView.Columns(0).Width = 100
        FpSpread1.ActiveSheetView.Columns(1).Width = 100

        FpSpread1.ActiveSheetView.Columns(0).BackColor = Drawing.Color.Yellow
        FpSpread1.ActiveSheetView.Columns(0).CellType = New TextCellType With {.AllowWrap = True}

        Dim intCell As New IntegerCellType
        intCell.MinimumValue = 1
        intCell.MaximumValue = 999

        GcCharacterTypeValidator1.ID = "dataTypeValidator1"
        GcCharacterTypeValidator1.ValidateOnInput = True
        GcCharacterTypeValidator1.CharacterSet = "9"
        GcCharacterTypeValidator1.ValidatorActionID = "GcValidatorAction1"

        Dim valProc As New ValueProcess
        valProc.ValueProcessOption = ValueProcessOption.Restore
        GcValidatorAction1.DefaultActions.Add(valProc)

        intCell.Validators.Add(GcCharacterTypeValidator1)

        FpSpread1.ActiveSheetView.Columns(1).CellType = intCell
    End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    </div>
        <FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="#A0A0A0" BorderStyle="Solid" BorderWidth="1px" Height="200" Width="400">
            <CommandBar BackColor="#F6F6F6" ButtonFaceColor="Control" ButtonHighlightColor="ControlLightLight" ButtonShadowColor="ControlDark">
            </CommandBar>
            <Sheets>
                <FarPoint:SheetView SheetName="Sheet1">
                </FarPoint:SheetView>
            </Sheets>
        </FarPoint:FpSpread>
        <im_validator:GcCharacterTypeValidator ID="GcCharacterTypeValidator1" runat="server" ErrorMessage="GcCharacterTypeValidator" HasLoadFromXml="True"></im_validator:GcCharacterTypeValidator>
        <im_extenders:GcValidatorAction ID="GcValidatorAction1" runat="server"></im_extenders:GcValidatorAction>
    </form>
</body>
</html>
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2018-4-25 15:18:03
5#
我试着重现问题
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2018-4-26 09:33:21
6#
测试了,使用validator后原有验证就失效了,需要您在Validator里实现所有验证

评分

参与人数 1满意度 +5 收起 理由
Catsou55 + 5

查看全部评分

回复 使用道具 举报
Catsou55
初级会员   /  发表于:2018-4-26 09:56:27
7#
谢谢您的回答。
InputMan只提供了下面六种验证控件,没有提供最大最小值的验证。
GcCharacterTypeValidator,GcDataTypeValidator,GcDateDifferenceValidator,
GcDateRangeValidator,GcForbiddenTextValidator,GcTextLengthValidator
需要实现自定义验证控件才能实现吗?
如何实现自定义验证控件能提供些帮助吗?
麻烦再帮忙看看,万分感激。
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2018-4-26 17:43:13
8#
也可以看看微软本身提供的一些Validator。 结合一起使用
回复 使用道具 举报
Catsou55
初级会员   /  发表于:2018-5-11 19:49:41
9#
日期时间型单元格(DateTimeCellType)也有同样的问题。绑定了InputMan的检证控件GcCharacterTypeValidator之后,
时间最大值最小值Check也会失效。还有没有别的解决方案。
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2018-5-14 09:01:50
10#
这个没有了,这个和之前一样,结合使用。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部