本帖最后由 tuifeishimei 于 2019-1-10 19:28 编辑
最近在用Spread For ASP.net(10.0.4000.2013)的时候,用到了InputMan制品里面的GcDateRangeValidator的控件(10.0.4000.2012),
但是检查日期的范围的时候,发现0001/01/01到0099/12/31这段期间不能被正确的(小于设定的最小值)检查出来。
现象如下,烦请各位高工帮忙看一下有什么问题。
现象1(最小值检查对一部分输入的日期:00010101-00991231没有生效)
现象2(服务器端postback事件里面的检查,检查的范围也是不准)※这个是次要问题,不解决也行。
日本官网的例子里面也是这个问题(现象1)。
代码(主要部分):
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- FpSpread1.SaveChanges()
- End Sub
- Private Sub PreRenderHandler(sender As Object, e As EventArgs) Handles Me.PreRender
- Dim sheet As SheetView = FpSpread1.ActiveSheetView
- sheet.RowCount = 10
- sheet.ColumnCount = 1
- sheet.Columns(0).Width = 200
- '表示形式:yyyy年MM月dd日、編集形式:yyyyMMdd
- sheet.Columns(0).CellType = CreateCellTypeWithImeValidatorForDateTime2(Me, 0, 8, "9", ImeMode.Disabled, "yyyy年MM月dd日", "yyyyMMdd")
- End Sub
- ''' <summary>
- ''' 日付CellType作成(年月日、年月、月日)
- ''' </summary>
- ''' <param name="columnIndex">SpreadSheet的列的索引</param>
- ''' <param name="maxLength">最大入力长度</param>
- ''' <param name="characterSet">入力的文字种别限制</param>
- ''' <param name="imeMode">IME设定</param>
- ''' <param name="dateDisplayFotmat">Spread表示格式</param>
- ''' <param name="dateEditFotmat">Spread編集格式</param>
- ''' <returns></returns>
- Private Function CreateCellTypeWithImeValidatorForDateTime2(mPage As Control, columnIndex As Integer, maxLength As Integer, characterSet As String, imeMode As ImeMode, dateDisplayFotmat As String, dateEditFotmat As String, Optional showCalc As Boolean = True) As FarPoint.Web.Spread.DateTimeCellType
- ' 验证Action設定
- Dim dateTimeValidatorActionSp As New GrapeCity.Web.Input.IMExtenders.GcValidatorAction With {
- .ID = "dateTimeValidatorActionSp"
- }
- ' 日期以外入力不可的动作
- Dim dateTimeValueProcessSp As New GrapeCity.Web.Input.IMExtenders.ValueProcess With {
- .ValueProcessOption = GrapeCity.Web.Input.IMExtenders.ValueProcessOption.Restore
- }
- dateTimeValidatorActionSp.DefaultActions.Add(dateTimeValueProcessSp)
- Dim dateRangeValidator As New GrapeCity.Web.Input.IMValidators.GcDateRangeValidator With {
- .MaximumDate = CDate("9999-12-31"),
- .MinimumDate = CDate("1900-01-01"),
- .ValidatorActionID = dateTimeValidatorActionSp.ID,
- .ErrorMessage = "日期的范围不正确,请输入19000101-99991231范围内的值"
- }
- ' 验证Action設定追加
- If mPage IsNot Nothing Then
- If IsNothing(Me.FindControl("dateTimeValidatorActionSp")) Then
- Me.Controls.Add(dateTimeValidatorActionSp)
- End If
- End If
- ' 日期型CellType设定及返回
- Dim dtc As New FarPoint.Web.Spread.DateTimeCellType() With {
- .FormatString = dateDisplayFotmat,
- .ShowPopupButton = showCalc
- }
- dtc.Validators.Add(dateRangeValidator)
- dtc.EditMode.FormatString = dateEditFotmat
- dtc.ImeMode = imeMode
- Return dtc
- End Function
复制代码
附件是代码的工程。
|
|