So, I have a page that contains a grid
SearchPage.razor
<FiGrid @ref="Grid"
<Columns>
@Columns
</Columns>
<EditFormTemplate Context="contextEntity">
@EditFormTemplate(contextEntity)
</EditFormTemplate>
</FiGrid>
@code{
protected RenderFragment Columns { get; set; }
protected RenderFragment<object> EditFormTemplate { get; set; }
}
this page has a RenderFragment to render the columns and one to render an editForm whenever is necessary
i inherit from this SearchPage to customize this 2 props:
CustomSearchPage.razor
@inherits SearchPage
@{
base.BuildRenderTree(__builder);
}
@code {
private static RenderFragment _customColumns = __builder =>
{
<CustomColumn FieldName="@nameof(Factory.Id)" Width="75px"/>
<CustomColumn FieldName="@nameof(Factory.BusinessName)"/>
<CustomColumn FieldName="@nameof(Factory.Address)"/>
};
private static RenderFragment<object> _customEditFormTemplate = editModel => __builder =>
{
<CustomEditForm Entity="editModel"/>;
};
protected override void OnInitialized()
{
Columns = _customColumns;
EditFormTemplate = _customEditFormTemplate;
base.OnInitialized();
}
}
but it gives me this error on the console:
Operation is not valid due to the current state of the object.
maybe I'm using the wrong approach, in that case, how should I accomplish the same thing?
I need to be able to inherit from a page and pass the page a custom edit form that takes the context of the template
basically I want to pass the context of the template down to a RenderFragment created via code