Dashboard Layout Panels incorrectly sized when using the Dashboard Layout component in conjunction with the Tab component
I have a Tab component where each tab item displays a separate Dashboard Layout. When the page first loads the panel items in the first tab are sized correctly based on the SizeX and SizeY properties that I have assigned them. However, if I switch to another tab then the panels are displayed with the wrong SizeX and SizeY values. When stepping through the code, I can see that during data binding properties SizeX and SizeY have the correct values. However, when I open the browser tools and select the elements that represent each panel, the SizeX and SizeY values are wrong. It looks as if they are being taken from those assigned to the first tab.
I am assigning unique IDs to each Tab Item, Dashboard Layout, and Dashboard Layout Panel.
What could be going wrong here? It should be possible to display multiple Dashboard Layouts on a page, one per Tab?
Attachment: Screenshots_19300cdc.zip
Hi Matthew,
Greetings from Syncfusion support.
With the provided details, we understand that you are facing an issue with the Blazor Dashboard Layout Panels being incorrectly sized when the Dashboard Layout component is rendered within the Tab, and you navigate between the tab items. To validate the issue, we have prepared a Dashboard sample where the panels are rendered within the Tab. In this sample, the panels are rendered correctly with their specified SizeX and SizeY values (along with their corresponding panel properties).
Sample : https://blazorplayground.syncfusion.com/hjryDzqDfFLJqKjr
However, we understand that you are experiencing this issue in your application. To assist you further, we need the following additional details:
1. How is the Dashboard component and Tab component rendered (with static data or dynamic data)?
2. During the tab navigation/selection, have you made any customizations to the Dashboard component or the panel properties?
3. How many tab items and panels are rendered in your application?
4. Are there any custom styles applied?
Please share the requested details. If possible, provide code snippets that replicate the issue, or demonstrate the issue using our shared sample. This information will help us validate the problem and provide a timely solution.
Regards,
Leo Lavanya Dhanaraj
Leo
Thanks for your message. In response to your questions:
- Both Dashboard and Tab components are rendered using dynamic data. Each Layout Panel within the Dashboard renders one of our own custom Blazor components. Users can add/remove items of their choosing from a Dashboard Layout, so components are loaded into a Layout Panel dynamically using DynamicComponent.
- Yes. I will prepare a sample which demonstrates how we are customizing the Dashboard and Panel components.
- At least one. Users can add and remove tabs from the page, so the number of tabs can vary.
- We do have some custom styles. However, I don't think any of these styles could be the cause of the problem.
Leo
As requested, please find attached a demo application 'DashboardDemo' which demonstrates the problem I'm having.
The application displays two tabs, each with their own Dashboard Layout. The first tab 'Home' displays OK. However when you switch to the second tab 'Revenue', the layout is twice as wide as it should be.
Also, if you switch back from the second tab to the first tab, it's no longer possible to change the order of the Dashboard Panels by dragging/dropping them.
Regards
Paul
Attachment: DashboardDemo_c8a3d1a9.zip
Can I get an update on this issue? I uploaded a sample application which demonstrates the problem I'm having 10 days ago but have not yet received a response.
Hi Matthew,
We sincerely apologize for the inconvenience and delay caused on our end. Due to the level of integration and customization in your sample, it took additional time to identify the exact root cause of the issue.
Issue 1: Layout width doubles when switching to the 'Revenue' tab:
In your sample, you have customized the Columns and CellAspectRatio values based on the number of panels rendered in the Dashboard Layout component. The second tab, 'Revenue' Dashboard panel is taking two columns of width value as per your input. For that reason, the panel is rendered with 2 SizeX and 1 SizeY value with columns of 2. To correct this, we recommend setting the columnWidth value to 0 for the 'Revenue' panel.
|
[Home.razor] @code { void BindDashboard() { Tabs = [ … new Models.DashboardTab { TabName = "Revenue", ColumnWidths = [0], Widgets = [ new Models.DashboardTabWidget { Id = 3, … } ] }, ]; } } |
Issue 2 : It's no longer possible to change the order of the Dashboard Panels by dragging/dropping them.
The dragging issue occurred because of duplicate IDs in the Dashboard Layout component (specifically, the same ID was assigned to the first panel of both Dashboard components). To resolve this, we recommend removing the manually assigned Id property from the panel. The component will automatically assign a unique ID to each panel.
|
[DashboardTab.razor] @if (IsReady) { <SfDashboardLayout @ref="DashboardLayoutComponent" … > <DashboardLayoutPanels> @foreach (var widget in Data.Widgets) { var widgetId = widget.Id; <DashboardLayoutPanel Row="@widget.RowIndex" Column="@widget.ColumnIndex" SizeX="@widget.SizeX" SizeY="@widget.SizeY"> … </DashboardLayoutPanel> } </DashboardLayoutPanels> </SfDashboardLayout> } |
Issue screenshot;
|
First tab – first panel |
Second tab – first panel |
|
|
|
For your reference, we have included the updated sample along with a working demonstration in the form of a video. Please review it on your end and let us know if you need any further assistance.
Attachment: Dashboard_cef5a647.zip
Leo
Thanks for getting back to me. I reviewed your updated sample. However, there is still a problem.
Please take a look at the attached sample application. I have added a tab named 'Bookings' to the Home page. The 'Home' and 'Bookings' tabs both make use of a shared component named 'BookingsByConsultant'. Try switching between the tabs in the order of the screenshots below. You will see that the 'BookingsByConsultant' component only displays correctly when the page first loads. Once you start changing the selected tab, the component displays incorrectly.
I have included a number of screenshots in the sample solution. They are numbered 1, 2, 3 etc in order of me changing tabs.
Regards
Paul
Attachment: DashboardDemo_8039fc3f.zip
Hi Matthew,
The reported issue occurs because the component is being rendered before the layout has fully completed rendering while navigating through tabs. We recommend refreshing the Dashboard component using the DashboardRefreshAsync method with a slight delay in the Selected event of the Tab. This ensures the component is re-rendered after the layout is finalized.
Also in your shared sample, the Accumulation Chart in the second tab(Bookings) appears larger due to the size of its parent element(Because the columns value set as 1 – due to this Dashboard panel is rendered as large with scrollbar presence).
We have attached modified sample and snippet for your reference.
|
[Home.razor] <SfTab ID="SfTab"> <TabEvents Selected="OnTabSelected"></TabEvents> <TabItems> @foreach (var tab in Tabs) { <TabItem ID="@($"TabItem-{tab.Id}")"> <ContentTemplate> <DashboardTab @ref="dashboardRef" Data="tab" /> </ContentTemplate> </TabItem> } </TabItems> </SfTab>
private DashboardTab dashboardRef; private async Task OnTabSelected(SelectEventArgs args) { if (dashboardRef != null) { await dashboardRef.DashboardRefreshAsync(); } } void BindDashboard() { Tabs = [ new Models.DashboardTab { TabName = "Home", Columns = 2, Widgets = [ … ] }, new Models.DashboardTab { TabName = "Bookings", Columns = 2, Widgets = [ new Models.DashboardTabWidget { Id = 1, Name = nameof(Components.Widgets.BookingsByConsultant), Title = "Bookings by Consultant", ComponentType = typeof(Components.Widgets.BookingsByConsultant), RowIndex = 0, ColumnIndex = 0, SizeX = 1, SizeY = 1 } ] }, … ]; }
[DashboardTab.razor] public async Task DashboardRefreshAsync() { await Task.Delay(200); // Wait for layout visibility
foreach (var component in DynamicDashboardComponents.Values) { if (component.Instance is WidgetBase widget) { await widget.Refresh(); } } } |
Attachment: DashboardDemo_42d71aab.zip
Leo
Thanks for your response. I checked your sample and the components on the dashboard tabs do now display correctly.
One thing I don't understand is why it's necessary to set 'Columns=2' for the 'Bookings' tab when it only contains a single component. The documentation ( Configuring the Grid Layout in Blazor Dashboard Layout | Syncfusion) states the following for the 'Columns' property:
Specifies the total number of cells in each row.
The 'Home' tab needs to have a 2-column layout because the 'Bookings by Consultant' component is configured to be twice as wide as the 'Options by Consultant'. But why does the 'Bookings' tab need a 2-column layout when there's only one cell to display?
Regards
Paul
Hi Matthew,
With the shared details, we were also able
to replicate the mentioned issue(Second Dashboard size) in the provided
sample. Upon further validation, we found that the sizeX and sizeY
values of the first Tab Dashboard panel (Home) are set to those of the second
Tab Dashboard panel
also(Bookings) but the
component Columns are properly set. We suspect that the issue occurs due
to the usage of common shared component page, and the panel properties are not
being refreshed correctly.
We attempted to resolve this issue by calling the RefreshAsync method during the Tab Selecting and Selected event, as well as in the Dashboard component's Created event. Unfortunately, the issue still persists. Due to the level of customization and configuration in your sample, we require additional time to validate this issue. We will provide you with further details on or before May 27, 2025. We appreciate your patience and understanding.
Leo
Do you have an update for me yet? It's now May 29th; you said I'd hear back by May 27th.
Thanks
Paul
Hi Matthew,
We sincerely apologize for the inconvenience and delay caused on our end. Due to the level of integration and customization in your sample, it took us additional time to identify the exact root cause of the issue.
Upon further validation, we discovered that a single Dashboard component is maintained across all the tabs, with only the panel property changing. This creates a position conflict in the Dashboard panel. To resolve this issue, we suggest using the @key and unique ID attributes for the SfDashboardLayout and DashboardLayoutPanel tags. For your reference, we have included the modified sample, code snippets, and output screenshots.
Here, we change the second Tab Dashboard column as per your application need.
|
[Home.razor] void BindDashboard() { Tabs = [ new Models.DashboardTab { TabName = "Home", Columns = 2, Widgets = [ new Models.DashboardTabWidget { Id = 1, Name = nameof(Components.Widgets.BookingsByConsultant), Title = "Bookings by Consultant", ComponentType = typeof(Components.Widgets.BookingsByConsultant), RowIndex = 0, ColumnIndex = 0, SizeX = 2, SizeY = 1 }, new Models.DashboardTabWidget { Id = 2, Name = nameof(Components.Widgets.OptionsByConsultant), Title = "Options by Consultant", ComponentType = typeof(Components.Widgets.OptionsByConsultant), RowIndex = 1, ColumnIndex = 1, SizeX = 1, SizeY = 1 } ] }, new Models.DashboardTab { TabName = "Bookings", Columns = 1, Widgets = [ new Models.DashboardTabWidget { Id = 4, Name = nameof(Components.Widgets.BookingsByConsultant), Title = "Bookings by Consultant", ComponentType = typeof(Components.Widgets.BookingsByConsultant), RowIndex = 0, ColumnIndex = 0, SizeX = 1, SizeY = 1 } ] }, new Models.DashboardTab { TabName = "Revenue", Columns = 2, Widgets = [ new Models.DashboardTabWidget { Id = 3, Name = nameof(Components.Widgets.RevenueByConsultant), Title = "Revenue by Consultant", ComponentType = typeof(Components.Widgets.RevenueByConsultant), RowIndex = 0, ColumnIndex = 0, SizeX = 1, SizeY = 1 } ] }, ]; }
[DashboardTab.razor] @if (IsReady) { <SfDashboardLayout @ref="DashboardLayoutComponent" ID="@($"DashboardLayout-{@Data.TabName}")" Columns="@Data.Columns" AllowFloating="true" AllowResizing="true" AllowDragging="true" EnablePersistence="true" CellSpacing="@Spacing" CellAspectRatio="1.8" ResizableHandles="ResizableHandle.SouthEast"> <DashboardLayoutPanels> @foreach (var widget in Data.Widgets) { var widgetId = widget.Id; <DashboardLayoutPanel @key="@(widget.Id)" Id="@widget.Id.ToString()" Row="@((int)widget.RowIndex)" Column="@((int)widget.ColumnIndex)" SizeX="@((int)widget.SizeX)" SizeY="@((int)widget.SizeY)"> <HeaderTemplate>@widget.Title</HeaderTemplate> <ContentTemplate> <div style="height: 100%; width: 100%;"> <DynamicComponent @ref="DynamicDashboardComponents[widgetId]" Type="widget.ComponentType" /> </div> </ContentTemplate> </DashboardLayoutPanel> } </DashboardLayoutPanels> <DashboardLayoutEvents OnResizeStop="OnResize" /> </SfDashboardLayout> } |
|
First Tab |
Second Tab |
Third tab |
|
|
|
|
Refer the shared details and get back to us if you need any further assistance.
Regards,
Leo Lavanya Dhanaraj
Attachment: DashboardDemo_af9a435c.zip
Leo
Thanks for this. I think your latest sample answers all my questions.
Regards
Paul
Thank you for the update. Please get back to us if you need any further assistance in the future.
- 13 Replies
- 2 Participants
-
MW Matthew Whalley
- Apr 29, 2025 03:00 PM UTC
- Jun 2, 2025 06:01 AM UTC