从 devextreme 表单中删除必填字段值
Remove required field value from devextreme form
我使用 asp.net mvc 和 devextreme
我有带有 bool 值的模型,我将在视图中添加表单
我的问题是,当我取消选中复选框时,我收到一条验证消息,checkForImges 字段是必需的
我想删除它和红色边框
查看代码
@model ArchiveConfigManager.Models.QueryRetrieve
@using DevExtreme.AspNet.Mvc
@(Html.DevExtreme().Form().ID("form")
.ShowValidationSummary(false).ShowRequiredMark(false).
ShowOptionalMark(false).
ShowColonAfterLabel(false)
.ColCount(1)
.Items(items =>
{
items.AddGroup()
.Items(groupItems =>
{
groupItems.AddSimple().DataField("CheckForImages").
IsRequired(false).Label(l => l.Visible(false)).
Editor(e => e.CheckBox().Text("Check For Images"))
;})
;})
.FormData(Model)
)
型号代码
public class QueryRetrieve
{
public bool CheckForImages { set; get; }
}
the result is
ASP.NET 框架会根据需要考虑任何 non-nullable 属性。因此,为避免此问题,您可以将 CheckForImages 属性 标记为可为空:
public class QueryRetrieve
{
public bool? CheckForImages { set; get; }
}
我使用 asp.net mvc 和 devextreme 我有带有 bool 值的模型,我将在视图中添加表单
我的问题是,当我取消选中复选框时,我收到一条验证消息,checkForImges 字段是必需的
我想删除它和红色边框
查看代码
@model ArchiveConfigManager.Models.QueryRetrieve
@using DevExtreme.AspNet.Mvc
@(Html.DevExtreme().Form().ID("form")
.ShowValidationSummary(false).ShowRequiredMark(false).
ShowOptionalMark(false).
ShowColonAfterLabel(false)
.ColCount(1)
.Items(items =>
{
items.AddGroup()
.Items(groupItems =>
{
groupItems.AddSimple().DataField("CheckForImages").
IsRequired(false).Label(l => l.Visible(false)).
Editor(e => e.CheckBox().Text("Check For Images"))
;})
;})
.FormData(Model)
)
型号代码
public class QueryRetrieve
{
public bool CheckForImages { set; get; }
}
the result is
ASP.NET 框架会根据需要考虑任何 non-nullable 属性。因此,为避免此问题,您可以将 CheckForImages 属性 标记为可为空:
public class QueryRetrieve
{
public bool? CheckForImages { set; get; }
}