Hi, I'm working with datagrids, and I made a custom grid component
that inherits from a grid. I need that grid inheritance because I need
to make a customizable grid with additional features that the web
designer can turn on/off while designing the website.
MyGrid.razor
@using Syncfusion.Blazor.Grids;
@typeparam TValue
@inherits SfGrid<TValue>
<CascadingValue Value="@this" IsFixed="false">
@ChildContent
</CascadingValue>
MyGrid.razor.cs
using Microsoft.AspNetCore.Components;
using Syncfusion.Blazor.Grids;
namespace MyProject
{
public partial class MyGrid<TValue>
{
[Parameter] public string GridName { get; set; }
}
}
The page that uses MyGrid
<MyGrid @ref="this.Grid" class="full-page-grid" GridName="OrderGrid" TValue="Order" ID="Grid" AllowSorting="true" AllowFiltering="true" AllowPaging="true" AllowResizing="true">
<SfDataManager AdaptorInstance="@typeof(CustomDataAdaptor)" Adaptor="Adaptors.CustomAdaptor">
</SfDataManager>
<GridPageSettings PageSize="16"></GridPageSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.Id) HeaderText="Id" IsPrimaryKey="true" Visible="false" TextAlign="TextAlign.Right" Width="0"></GridColumn>
<C2GridColumnTooltip TItem="Order" Field=@nameof(Order.Name) HeaderText="Name" AllowFiltering="true" AllowEditing="false"></C2GridColumnTooltip>
<C2GridColumnTooltip TItem="Order" Field=@nameof(Order.Address) HeaderText="Address" AllowFiltering="true" AllowEditing="false"></C2GridColumnTooltip>
</GridColumns>
<GridEvents OnActionFailure="ActionFailureHandler" TValue="order"></GridEvents>
</MyGrid>
<style>
.full-page-grid {
width: 100%;
height: 98%;
}
.full-page-grid > .e-gridpager {
position: absolute;
bottom: 0;
} </style>
The issue
But then page didn't render the grid component, and not shows any error in the console.
Thanks for your help.
Hi Antonio,
Welcome from Syncfusion support.
Currently, we are validating your sample at our end. Further details will be
updated within two business days.
Until then we appreciate your patience.
Regards,
Keerthana.
Hi Antonio,
Greetings from Syncfusion support.
Query: Inherited grid did not render.
We have analyzed your query and we suspect that the grid is not
rendered because MyGrid.razor.cs is not an inherited class. We have made
a solution file based on your requirement. Kindly refer to the attached
solution file for your reference.
Kindly get back to us if you have any further queries.
Regards,
Keerthana.
In my experienc ethe best way to create an inherited grid is to avoid completely the usage of a blazor file
I made something similar and this was enough:
public class MyGrid<TValue> : SfGrid<Tvalue>
{
[Parameter]
public string GridName { get; set; }
}
If you want to manage default parameters you can override the SetParametersAsync and manage the parameter presence there.
Hi Michele
Thanks for your suggestions
Please let us know if you have any concerns.
Regards,
Naveen Palanivel