Default DataGrid Properties

Hello,
Is there a way to define the default DataGrid properties from one place in the entire App (all pages)?
Properties like:

AllowColumnResize="true"
Density="Density.Compact"
AllowPaging="true"
PagerHorizontalAlign="HorizontalAlign.Center" 
ShowPagingSummary="true"
PagerAlwaysVisible="true"
PageSize="10"
AllowColumnPicking="true"
etc ...

For example, something like:
<RadzenDataGrid @ref="grid0" DefaultSettings="@MyDefaultGirdSettings" ....

You can create new compound inherited from RadzenDataGrid and set desire properties.

Nice idea! Worked perfectly for me.
Thank you :pray:

Hello @enchev,
do you have any examples for creating a new compound based in Radzen datagrid?
Default properties fΓΌr Datagrid are very nice!

Thank you
Thomas

Hey @Thomas,

You just need a .razor file where you can declare desired component and specify from which component inherits. Similar example (no declaration, just overrides) can be found in DataFilter demos:

Great! Thank you!

Thomas

I used this:

public class RadzenDataGridX<TItem> : RadzenDataGrid<TItem>
{
	public RadzenDataGridX()
	{
		// Pager:
		AllowPaging          = true;
		PagerHorizontalAlign = HorizontalAlign.Center;
		ShowPagingSummary    = true;
		PagerAlwaysVisible   = true;
		PageSize             = 10;
		PageSizeOptions      = new[] { 10, 15, 20, 30, 50 };
		// Columns:
		AllowSorting         = true;
		AllowColumnResize        = true;
		AllowRowSelectOnRowClick = true;
	}
}

Usage:

<RadzenDataGridX @ref="grid0" .....>
</RadzenDataGridX >
1 Like

I have created a new component that inherits from RadzenDataGrid called AnchorRadzenDataGrid. One reason I wanted to wrap the DataGrid was to automatically save and load settings internally in the new AnchorRadzenDataGrid component for all my grids that use the new AnchorRadzenDataGrid component. However I'm not sure how to use the @bind-Settings="@Settings" inside the new component where I inherits the RadzenDataGrid. Can you show an example on how this can be done, if possible?