Hi,
I am using Blazor WebAssembly 19.3.0.48 and I tried the custom grid component example.
However, I can’t get it to work. I have the following error: “Unhandled exception rendering component: Value cannot be null. (Parameter 'source')”.
1) Can you provide me with an example of custom grid component for WebAssembly?
2) Can I override a fragment of the custom grid component?
For instance, override GridPageSettings of CustomGrid.razor in Index.razor like this:
@* CustomGrid.razor *@
<SfGrid TValue="TValue" AllowSorting="AllowSorting" AllowPaging="AllowPaging" @attributes="props">
@* Default GridPageSettings. *@
<GridPageSettings PageCount="2" PageSize="5" />
@ChildContent
</SfGrid>
@* Index.razor *@
<CustomGrid DataSource="Orders" TValue="Order">
@* Override GridPageSettings. *@
<GridPageSettings PageCount="5" PageSize="10" />
</CustomGrid>
Thanks for your help.
Best regards.
François
|
[Index.razor]
<CustomGrid DataSource="Orders" TValue="Order" IsOverridePageSettgings="true">
<GridPageSettings PageCount="5" PageSize="10" />
</CustomGrid> |
|
[CustomGrid.razor]
<SfGrid TValue="TValue" AllowSorting="AllowSorting" AllowPaging="AllowPaging" @attributes="props">
@ChildContent
@if (!IsOverridePageSettgings)
{
<GridPageSettings PageCount="PAGE_COUNT" PageSize="DEFAULT_PAGE_SIZE" PageSizes="PageSizes"></GridPageSettings>
}
</SfGrid> |
|
[CustomGrid.razor.cs]
public partial class CustomGrid<TValue> : SfGrid<TValue>
{
public const int PAGE_COUNT = 2;
public const int DEFAULT_PAGE_SIZE = 5;
[Parameter]
public bool IsOverridePageSettgings { get; set; }
public string[] PageSizes = new string[] { "5","10", "20", "50" };
. . .
} |
Hi Rahul,
Thanks for your answer.
I updated with the last Syncfusion NuGet and the custom grid component works.
Regarding my second query, I tested both my solution and yours (see CustomGrid1 and CustomGrid2 in my attached example). Both solutions work.
Is there a recommended solution? And why is it recommended?
Thanks again.
Best Regards.
François