Amer
February 5, 2023, 1:26pm
1
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" ....
enchev
February 5, 2023, 1:38pm
2
You can create new compound inherited from RadzenDataGrid and set desire properties.
Amer
February 5, 2023, 7:36pm
3
Nice idea! Worked perfectly for me.
Thank you
Thomas
February 6, 2023, 7:37am
4
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
enchev
February 6, 2023, 7:45am
5
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:
Amer
February 6, 2023, 8:17am
7
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