Allow custom styling when implementing a custom RadzenDataGridColumn.cs #826

Closed
opened 2026-01-29 17:44:57 +00:00 by claunia · 1 comment
Owner

Originally created by @Arturace on GitHub (Apr 27, 2023).

Is your feature request related to a problem? Please describe.
I was making a component that inherits RadzenDataGridColumn, so I can customize the default values and behaviours of the column. I got to the part where I needed custom styling on the heading of the column. Specifically, I needed to override the style set on a DataGrid by some css, by setting --rz-grid-header-background-color on that custom column.

Describe the solution you'd like
I checked the source code, and there are 2 ways the column impacts RadzenDataGridHeaderCell.razor:

  1. With HeaderCssClass which would force me to make the css class out of scope of my custom column component;
  2. With RadzenDataGridColumn.GetStyle(bool, bool) which is not overridable.

I would like RadzenDataGridColumn.GetStyle(bool, bool) to be virtual, to allow for custom styling on the column without passing by global css classes.

Describe alternatives you've considered
I can inject css styling by using Width and MinWidth properties of the RadzenDataGridColumn. Hacky, but works.

Additional context
If the solution is alright with a contributor, I will make a PR to make the method virtual.

Originally created by @Arturace on GitHub (Apr 27, 2023). **Is your feature request related to a problem? Please describe.** I was making a component that inherits `RadzenDataGridColumn`, so I can customize the default values and behaviours of the column. I got to the part where I needed custom styling on the heading of the column. Specifically, I needed to override the style set on a DataGrid by some css, by setting `--rz-grid-header-background-color` on that custom column. **Describe the solution you'd like** I checked the source code, and there are 2 ways the column impacts `RadzenDataGridHeaderCell.razor`: 1. With `HeaderCssClass` which would force me to make the css class out of scope of my custom column component; 2. With `RadzenDataGridColumn.GetStyle(bool, bool)` which is not overridable. I would like `RadzenDataGridColumn.GetStyle(bool, bool)` to be virtual, to allow for custom styling on the column without passing by global css classes. **Describe alternatives you've considered** I can inject css styling by using `Width` and `MinWidth` properties of the `RadzenDataGridColumn`. Hacky, but works. **Additional context** If the solution is alright with a contributor, I will make a PR to make the method virtual.
Author
Owner

@Arturace commented on GitHub (Apr 28, 2023):

Thank you very much @enchev!

@Arturace commented on GitHub (Apr 28, 2023): Thank you very much @enchev!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#826