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