[Feature Request] RadzenDataGrid - allow EditTemplate #994

Closed
opened 2026-01-29 17:47:28 +00:00 by claunia · 6 comments
Owner

Originally created by @viceroypenguin on GitHub (Sep 26, 2023).

I would like to update RadzenDataGrid such that it is possible to flow EditContext to an EditTemplate for a given row that is currently being edited, similar to the Template property.

Purpose: I currently have a row that has too much data to show in a single table row, so I put additional columns into the <Template/> property to be displayed when using the expand button. I would like to be able to edit these fields under the row's EditContext (using validation, etc.). To me, it would make sense to update RadzenDataGridRow.razor#L138 as follows:

@if (Grid.IsRowInEditMode(Item) && Grid.EditTemplate != null)
{
 <CascadingValue Value=@EditContext>
  @Grid.EditTemplate(Item)
 </CascadingValue>
}
else
{
  @Grid.Template(Item)
}

I can provide a PR for this if it would help.

Originally created by @viceroypenguin on GitHub (Sep 26, 2023). I would like to update `RadzenDataGrid` such that it is possible to flow `EditContext` to an `EditTemplate` for a given row that is currently being edited, similar to the `Template` property. Purpose: I currently have a row that has too much data to show in a single table row, so I put additional columns into the `<Template/>` property to be displayed when using the expand button. I would like to be able to edit these fields under the row's `EditContext` (using validation, etc.). To me, it would make sense to update RadzenDataGridRow.razor#L138 as follows: ``` @if (Grid.IsRowInEditMode(Item) && Grid.EditTemplate != null) { <CascadingValue Value=@EditContext> @Grid.EditTemplate(Item) </CascadingValue> } else { @Grid.Template(Item) } ``` I can provide a PR for this if it would help.
Author
Owner

@enchev commented on GitHub (Sep 27, 2023):

Hey @viceroypenguin,

I think you can add even now without any changes RadzenTemplateForm in the DataGrid Template to achieve desired effect (editing with validation, etc.):
image
image

@enchev commented on GitHub (Sep 27, 2023): Hey @viceroypenguin, I think you can add even now without any changes RadzenTemplateForm in the DataGrid Template to achieve desired effect (editing with validation, etc.): ![image](https://github.com/radzenhq/radzen-blazor/assets/5804953/fbdc02c9-fba1-4670-84d9-7ddd1266c234) ![image](https://github.com/radzenhq/radzen-blazor/assets/5804953/a3019def-e607-4dfc-acad-119ef8b827a5)
Author
Owner

@viceroypenguin commented on GitHub (Sep 27, 2023):

@enchev Thank you for your response. However, RadzenTemplateForm does not do what I am requesting here. Specifically, it does not attach the elements in the Template to the EditContext of the row; it creates a new EditContext for the dropdown area independent of the row. This means that actions take on the row do not affect items inside the template area.

Here, I have followed your instructions and added a RadzenTemplateForm, as well as a RadzenRequiredValidator.
image

If I add a new order and click save without filling anything in, notice that the Ship Name box gets a validation, but the Country box does not - the Country box is not affected by the save trigger from the row's EditContext.
image

@viceroypenguin commented on GitHub (Sep 27, 2023): @enchev Thank you for your response. However, `RadzenTemplateForm` does not do what I am requesting here. Specifically, it does not attach the elements in the `Template` to the `EditContext` of the row; it creates a new `EditContext` for the dropdown area independent of the row. This means that actions take on the row do not affect items inside the template area. Here, I have followed your instructions and added a `RadzenTemplateForm`, as well as a `RadzenRequiredValidator`. ![image](https://github.com/radzenhq/radzen-blazor/assets/1992555/74cecdd0-cfdc-4c48-9001-9916ace17b55) If I add a new order and click save without filling anything in, notice that the `Ship Name` box gets a validation, but the `Country` box does not - the Country box is not affected by the save trigger from the row's `EditContext`. ![image](https://github.com/radzenhq/radzen-blazor/assets/1992555/64e1cf50-6085-464d-8cbe-4160c41a04aa)
Author
Owner

@enchev commented on GitHub (Sep 27, 2023):

Using validators in the way you've implemented this template is not supported either:
image
image

I'm afraid that we cannot accept such pull request

@enchev commented on GitHub (Sep 27, 2023): Using validators in the way you've implemented this template is not supported either: ![image](https://github.com/radzenhq/radzen-blazor/assets/5804953/67fadb48-5745-4567-835a-3677c33eeb6d) ![image](https://github.com/radzenhq/radzen-blazor/assets/5804953/bcec9a5a-b49c-4dcc-afe2-31b41f526ced) I'm afraid that we cannot accept such pull request
Author
Owner

@viceroypenguin commented on GitHub (Sep 27, 2023):

Apologies, thanks for the catch. I mixed up some of the code when saving the final version for PR purposes. If you check out the updated branch (https://github.com/viceroypenguin/radzen-blazor/tree/edittemplate), this works as expected with the validator inside the EditTemplate.

Update is as follows, adding an additional CascadingValue:
image

@viceroypenguin commented on GitHub (Sep 27, 2023): Apologies, thanks for the catch. I mixed up some of the code when saving the final version for PR purposes. If you check out the updated branch (https://github.com/viceroypenguin/radzen-blazor/tree/edittemplate), this works as expected with the validator inside the `EditTemplate`. Update is as follows, adding an additional `CascadingValue`: ![image](https://github.com/radzenhq/radzen-blazor/assets/1992555/b98b9590-6462-4c8d-ad31-dc3a2cfd16ea)
Author
Owner

@enchev commented on GitHub (Sep 27, 2023):

I've verified the demo and it work as should - you can remove the code from the demo and submit new pull request with just the relevant component changes

@enchev commented on GitHub (Sep 27, 2023): I've verified the demo and it work as should - you can remove the code from the demo and submit new pull request with just the relevant component changes
Author
Owner

@viceroypenguin commented on GitHub (Sep 27, 2023):

Done, thanks!

@viceroypenguin commented on GitHub (Sep 27, 2023): Done, thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#994