Accessing EditContext from Grid
Hi,
I am trying to access the edit context when using the grid, is it something possible?
<GridEditSettings AllowAdding="true"
AllowDeleting="true"
AllowEditing="true"
Dialog="DefaultSettings.DialogSettings()"
Mode="EditMode.Dialog"
ShowDeleteConfirmDialog="true">
<Validator>
<DataAnnotationsValidator/>
</Validator>
<HeaderTemplate>
@{
var programDetail = context as ProgramDetailDto;
<span>@(programDetail.Id == default ? "New Version" : $"Edit {programDetail.Version}")</span>
}
</HeaderTemplate>
<Template>
@{
var programDetail = context as ProgramDetailDto;
<ProgramDetailForm @bind-ProgramDetail="programDetail"
EnvironmentId="EnvironmentId"
ProgramId="ProgramId"
EditContext=""/>
}
</Template>
</GridEditSettings>
AllowDeleting="true"
AllowEditing="true"
Dialog="DefaultSettings.DialogSettings()"
Mode="EditMode.Dialog"
ShowDeleteConfirmDialog="true">
<Validator>
<DataAnnotationsValidator/>
</Validator>
<HeaderTemplate>
@{
var programDetail = context as ProgramDetailDto;
<span>@(programDetail.Id == default ? "New Version" : $"Edit {programDetail.Version}")</span>
}
</HeaderTemplate>
<Template>
@{
var programDetail = context as ProgramDetailDto;
<ProgramDetailForm @bind-ProgramDetail="programDetail"
EnvironmentId="EnvironmentId"
ProgramId="ProgramId"
EditContext=""/>
}
</Template>
</GridEditSettings>
---
Form:
<div class="gap-3 grid grid-cols-2 p-3">
<div class="col-span-2">
<ValidationErrorDisplay EditContext="EditContext"/>
</div>
<div class="col-span-2">
<ValidationErrorDisplay EditContext="EditContext"/>
</div>
</div>
---
ValidationErrorDisplay:
@if (EditContext.GetValidationMessages()
.Any())
{
<Alert Severity="Severity.Error">
<h3 class="font-medium text-red-800 text-sm">One or more validation error occured.</h3>
<div class="mt-2">
<ul class="list-disc pl-5 space-y-1"
role="list">
@foreach (var message in EditContext.GetValidationMessages())
{
<li class="text-red-700 text-sm">@message</li>
}
</ul>
</div>
</Alert>
}
.Any())
{
<Alert Severity="Severity.Error">
<h3 class="font-medium text-red-800 text-sm">One or more validation error occured.</h3>
<div class="mt-2">
<ul class="list-disc pl-5 space-y-1"
role="list">
@foreach (var message in EditContext.GetValidationMessages())
{
<li class="text-red-700 text-sm">@message</li>
}
</ul>
</div>
</Alert>
}
Thank you
SIGN IN To post a reply.
1 Reply
1 reply marked as answer
NP
Naveen Palanivel
Syncfusion Team
July 10, 2023 08:34 AM UTC
Hi Alexandre,
From your update , we understand that you want to access the
EditContext from the grid. We have already addressed this topic in our User
Guide documentation. Kindly refer to the attached documentation link for
detailed information.
Reference: https://blazor.syncfusion.com/documentation/datagrid/column-validation#custom-validator-component
If it doesn’t meet your requirement then kindly share the below details to validate further at our end.
- Share us the entire Grid code snippet along with Code section
- Share more details about your requirement with elaborately
- Share us the video demonstration of the issue with elaborately , it will more useful to us.
- If possible share us an simple issue reproduceable sample
The above-requested details will be very helpful for us to validate the reported query at our end and provide the solution as early as possible
Regards,
Naveen Palanivel
Marked as answer
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
- Marked answer
-
AP Alexandre Pereira
- Jul 7, 2023 07:24 AM UTC
- Jul 10, 2023 08:34 AM UTC