Dashboard - Using a non-page component

Instead of putting a SF control inside the ContentTemplate can we put a non-page razor component? Have tried it and it doesn't seem to work. Is it supported? If not, will it?

Thanks.


1 Reply

SA SureshRajan Alagarsamy Syncfusion Team August 8, 2024 05:56 PM UTC

Hi Shawn,


We have reviewed your query and understand that you are looking to render the non-razor components inside the Dashboard Layout component ContentTemplate property. To achieve this, we have used a RenderFragment type to render the content dynamically within the ContentTemplate property.


Refer to the below code snippet for further reference.


[Index.razor]

 

<SfDashboardLayout CellSpacing="@(new double[]{20 ,20 })" Columns="5" MediaQuery="max-width:700px">

    <DashboardLayoutPanels>

        <DashboardLayoutPanel>

            <ContentTemplate>

                @RenderFragmentContent

            </ContentTemplate>

        </DashboardLayoutPanel>

        ....

    </DashboardLayoutPanels>

</SfDashboardLayout>

 

@code{

    RenderFragment RenderFragmentContent => builder =>

    {

        builder.OpenComponent(0, typeof(MyComponent));

        builder.AddAttribute(1, "Message", "This is a dynamic component inside DashboardLayout!");

        builder.CloseComponent();

    };

}


We have attached sample for your reference.


Sample : Attached as zip folder.


Could you please confirm if this approach meets your requirements for the DashboardLayout component? If not, we would appreciate any additional details or examples of the non-Razor components you are using. These details will help us to validate the query further and provide you with a prompt solution.


Regards,
Suresh.


Attachment: BlazorDashboardLayoutNonRazor_ce370a18.zip

Loader.
Up arrow icon