Showing Error Messages/Validation Summary displayed as a tooltip on the Grid Column When Using FluentValidation

Hello,


I've attached the code to replicate the scenario when using FluentValidation instead of DataAnnotations/CustomValidation method to validate with SfGrid.

I would like to render the error messages from FluentValidation in form of tooltips on top of grid columns (similar to default styling when using Data Annotation) when using SfGrid with GridEditSettings Mode set to "EditMode.Normal"


I would like to know if there is any way to achieve the above-mentioned case?


With best regards

Afshin~


Attachment: BlazorApp1_5c87456a.rar

1 Reply 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team December 21, 2021 09:36 AM UTC

Hi Afshin, 
 
Greetings from Syncfusion support. 
 
We have modified the shared sample to display tooltip on validation in Grid. Please download the modified sample from the link below, 
 
We have modified the below highlighted codes from your shared sample and also removed some unwanted packages in the above attached application. Please refer the codes below, 
 
 
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="@EditMode.Normal"> 
        <Validator> 
            @{ 
                ValidatorTemplateContext txt = context as ValidatorTemplateContext; 
            } 
            <FluentValidator contextnew="@txt" TValidator="CustomerValidator"></FluentValidator> 
            <ValidationSummary /> 
        </Validator> 
    <Template> 
        ... 
    </Template> 
</GridEditSettings> 
 
[Parameter]public ValidatorTemplateContext contextnew { getset; }
 
private void ValidateModel(EditContext editContext, ValidationMessageStore messages){    ...    foreach (var error in validationResult.Errors)    {        var fieldIdentifier = ToFieldIdentifier(editContext, error.PropertyName);        messages.Add(fieldIdentifier, error.ErrorMessage);        contextnew.ShowValidationMessage(fieldIdentifier.FieldName, false, error.ErrorMessage);    }    editContext.NotifyValidationStateChanged();}
 
 
Please get back to us if you need further assistance. 
 
Regards, 
Renjith R 


Marked as answer
Loader.
Up arrow icon