<TelerikForm Model="@Service.DataModel"
Width="1000px"
Columns="1"
ColumnSpacing="20px"
ValidationMessageType="FormValidationMessageType.Inline"
OnValidSubmit="@OnSubmitClick">
<FormValidation>
<FluentValidationValidator Validator="@FormValidator" DisableAssemblyScanning="@true"></FluentValidationValidator>
</FormValidation>
<FormItems>
<FormGroup Columns="3" ColumnSpacing="10px">
<FormItem Class="k-form-input-field" LabelText="Source File:" Field="@nameof(Service.DataModel.OriginalFileName)" Enabled="false"/>
<FormItem Class="k-form-input-field" LabelText="Document Name:" Field="@nameof(Service.DataModel.Name)" Enabled="@Service.IsAddMode"/>
<FormItem Class="k-form-input-field w290" LabelText="Version:" Field="@nameof(Service.DataModel.Version)" Enabled="false">
<Template>
<label for="type" class="k-label k-form-label">Version:</label>
<label>@(Service.DataModel.Version.HasValue ? DateTime.FromBinary(Service.DataModel.Version.Value).ToString("G") : "")</label>
</Template>
</FormItem>
</FormGroup>
<FormGroup Columns="3" ColumnSpacing="10px">
<FormItem Field="@nameof(Service.DataModel.Type)" Enabled="@Service.IsAddMode">
<Template>
<label for="type" class="k-label k-form-label">Type:</label>
<TelerikDropDownList id="type" Data="@Service.Types" @bind-Value="@Service.DataModel.Type.Key"
OnChange="@Service.TypeChanged"
ValueField="@nameof(GlossaryItem<string, string>.Key)"
TextField="@nameof(GlossaryItem<string, string>.Value)"
DefaultText="Select..." Width="290px" />
</Template>
</FormItem>
<FormItem Field="@nameof(Service.DataModel.Status)">
<Template>
<label for="status" class="k-label k-form-label">Status:</label>
<TelerikDropDownList id="status" Data="@Service.Statuses" @bind-Value="@Service.DataModel.Status.Key"
ValueField="@nameof(GlossaryItem<string, string>.Key)"
TextField="@nameof(GlossaryItem<string, string>.Value)"
DefaultText="Select..." Width="290px" Enabled="@(!string.IsNullOrEmpty(Service.DataModel.Type.Key))"/>
</Template>
</FormItem>
<FormItem Field="@nameof(Service.DataModel.IsActive)">
<Template>
<label for="IsActive" class="k-label k-form-label">Active:</label>
<TelerikCheckBox id="IsActive" @bind-Value="@Service.DataModel.IsActive"></TelerikCheckBox>
</Template>
</FormItem>
</FormGroup>
<FormGroup Columns="1" ColumnSpacing="10px">
<FormItem Field="@nameof(Service.DataModel.Agencies)">
<Template>
<label for="jurisdiction" class="k-label k-form-label">Agency / Authority:</label>
<TelerikMultiSelect id="jurisdiction" Data="@Service.Agencies"
@bind-Value="@Service.SelectedAgencies"
TextField="Value" ValueField="Key"
ScrollMode="@DropDownScrollMode.Virtual"
PageSize="10"
ItemHeight="35"
Filterable="true"
TValue="int" TItem="GlossaryItem<int, string>"/>
<TelerikValidationMessage For="@(() => Service.Agencies)" />
</Template>
</FormItem>
public class DocumentEditFormValidator : AbstractValidator<DocumentModel>
{
public DocumentEditFormValidator()
{
RuleFor(x => x.Name)
.NotEmpty()
.WithMessage("Document name can't be empty");
RuleFor(x => x.Type.Key)
.NotEmpty()
.WithMessage("Type must be set");
RuleFor(x => x.Status.Key)
.NotEmpty()
.WithMessage("Status must be set");
RuleFor(x => x.Agencies)
.NotEmpty()
.When(_=> _.Type.Key != "DD")
.WithMessage("Agency / Authority can't be empty");
}
}
so, multy & dll behaves differently, dll has red border, multi does not, but both do not show validation message