Coulmn Validation in Blazor,
When I use custom validations in Grids, I noticed that it gets stuck in breakpoint twice during debugging. When you use an API to control a field and fetch data from the database, this call happens twice, which is not interesting in terms of performance. Do you know any way to solve this problem?
https://blazor.syncfusion.com/documentation/datagrid/column-validation#custom-validation
Attachment: TEST_ca568981.rar
Hi Sam,
We reviewed your query and it seems that when using custom validation, it
appears to trigger twice. To resolve this issue, we recommend using the DataAnnotationValidator
component, which ensures that the validation is triggered only once during
custom validation. Please refer to the code snippet below for more details.
|
<SfGrid DataSource="EmployeeList" AllowPaging="true" Toolbar="toolbar"> <GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true"> <Validator> <DataAnnotationsValidator></DataAnnotationsValidator> </Validator> </GridEditSettings> <GridColumns> |
Please get back to us if you have any concerns.
Regards,
Naveen
Hi Naveen
Thank you for your kindness, yes your opinion is correct. I had tested both methods and noticed this bug and just wanted to let you know so that you are also aware and can fix it if needed.
Thank you
Hi Sam,
Currently Validating the reported query at our end with high priority and we
will update the further details within two days( 12th Dec, 2024).
Until then we appreciate your patience.
Regards,
Naveen.
Hi Sam,
We would like to inform you that the Grid uses two validator components by
default to handle validation. These components are the DataAnnotationValidator,
which handles validations based on data annotations, and Internal
ValidationRules, which validates according to the rules defined in the grid’s
ValidationRules property. The reason for the double trigger of validation is
that both validators are executed during the validation process. As a result,
the custom validation logic is triggered twice. This behavior is expected, as
it ensures that both custom validation rules and annotation-based validations
are respected.
Regards,
Naveen
Hi Naveen
Based on your explanation, it seems logical to enable validations twice
Best wishes to your team,
Sam
Hi Sam,
Thank
you for your understanding
Kindly get back to us if you have further queries. As always we will be happy
to assist you.
Regards,
Naveen