Panel height to remain fixed
Hello,
In responsive layout, panel height in Dashboard layout increases a lot. Is there a way to control height of panel when browser page is resized or viewing device is mobile?
My layout is simple with 2 panels as below.
@using Syncfusion.Blazor.Layouts
<SfDashboardLayout CellSpacing="@(new double[]{5 ,5 })" Columns="12" MediaQuery="max-width:700px">
<DashboardLayoutPanels>
<DashboardLayoutPanel Id="MidCenterPanel" Column=1 Row=0 SizeX=10 SizeY=32>
<ContentTemplate><div>0</div></ContentTemplate>
</DashboardLayoutPanel>
<DashboardLayoutPanel Id="BottomPanel" Column=0 Row=33 SizeX=12 SizeY=1>
<ContentTemplate><div>1</div></ContentTemplate>
</DashboardLayoutPanel>
</DashboardLayoutPanels>
</SfDashboardLayout>
<style>
.e-panel-content {
text-align: center;
margin-top: 10px;
}
</style>
When I tried this layout at https://blazorplayground.syncfusion.com/ with Browser developer tools, width and height of Panel '0' is 654.729 x 1465.9 which when changed to responsive device (or any mobile listed in chrome) width and height of same Panel becomes 354.36 x 6553.9. In this case, width reduction is okay, but height increases a lot. Is it possible to keep height at same at around 1465.9. Thanks.
Regards,
Prasanth Madhaiyan.
Hi Prasanth,
Thanks. I have already seen the link that you have shared for a feature request. This feature request seems to be old request, and comment suggests that it has been implemented in the product. But, I could not understand how it got implemented or how to use it from the reply. I also tried setting maximum height MaxSizeY for a panel, but that too did not work.
Is there a way to control height through stylesheet css? If yes, please let me know.
I am searching for various ways , but not finding a concrete solution yet.
<SfMediaQuery @bind-ActiveBreakpoint="@activeBreakpoint"></SfMediaQuery> <h3>The active breakpoint is @activeBreakpoint</h3> <SfDashboardLayout CellSpacing="@(new double[] { 5, 5 })" Columns="12" CellAspectRatio="@CellAspectRatio" MediaQuery="max-width:700px"> <DashboardLayoutPanels> <DashboardLayoutPanel Id="MidCenterPanel" Column=1 Row=0 SizeX=10 SizeY=32> <ContentTemplate><div>0</div></ContentTemplate> </DashboardLayoutPanel> <DashboardLayoutPanel Id="BottomPanel" Column=0 Row=33 SizeX=12 SizeY=1> <ContentTemplate><div>1</div></ContentTemplate> </DashboardLayoutPanel> </DashboardLayoutPanels> </SfDashboardLayout> @{ if (activeBreakpoint == "Small") { CellAspectRatio = 2; } else { CellAspectRatio = 1; } } @code { private string activeBreakpoint; private double CellAspectRatio = 1; // Sample Initialization protected override void OnInitialized() { SfMediaQuery.Small.MediaQuery = "(max-width: 700px)"; SfMediaQuery.Medium.MediaQuery = "(min-width:1200px)"; SfMediaQuery.Large.MediaQuery = "(min-width: 1600px)"; } } <style> .e-panel-content { text-align: center; margin-top: 10px; } </style> |
Regards,
Prasanth Madhaiyan.
Attachment: BlazorApp1_2606194b.zip
Hi Prasanth,
Thanks. Looks like you created sample attachment with net9.0 whereas I use net8.0. I tried modifying for dotnet 8 and build it, but again few static assets were missing. Eventually I built but started getting some runtime error. Sorry, I am not very good at dotnet or syncfusion. Could you please rebuild at your end with net8.0 and syncfusion version 26.2.8.
Also, I tried code snippet directly in blazor playground and it is not giving expected result. I am suspecting that CellAspectRation is not getting modified as expected for 'small' breakpoint. please help.
Hi Prasanth,
As per Syncfusion documentation, default mediaquery applies at 600px and then panels get stacked vertically. Vertical stacking is fine, but syncfusion also changes height of panels. Changing CellAspectRatio dynamically as provided by you is not working (atleast when tried in syncfusion playground). I also tried changing panel parameters (sizey, row) dynamically from code in method OnAfterRenderAsync(), but that too did not work.
Can you please talk to syncfusion product development team and ask if there is any way we can control panel height in responsive layout.
Other option, as suggested by you, is to use setting MediaQuery="(max-width:300px)". I already tried this option, but it has other consequences. My grid table in normal page layout contains 50 records per page and as screen width goes decreasing for small viewport (mobile device), it can accommodate only 20 or even less records. So, in that case, data will be spread across many number of pages (user requires to keep selecting next page more). If I allow data records to overflow, then my bottom panel below data grid panel gets overwritten.
Somehow, I feel like this is very common requirement for responsive behaviour and hence curious to know how other people solve this problem.
... @using Syncfusion.Blazor.Layouts @using Syncfusion.Blazor.Grids <SfMediaQuery @bind-ActiveBreakpoint="@activeBreakpoint"></SfMediaQuery> <SfDashboardLayout @ref="dashboard" CellSpacing="@(new double[] { 5, 5 })" Columns="12" CellAspectRatio="@CellAspectRatio" MediaQuery="max-width:300px"> <DashboardLayoutPanels> <DashboardLayoutPanel Id="MidCenterPanel" Column=1 Row=0 SizeX="10" SizeY="3"> <ContentTemplate> <SfGrid DataSource="@GridData" AllowPaging="true" Width="100%" Height="100%"> <GridPageSettings PageSize="50"></GridPageSettings> <GridColumns> <GridColumn Field=@nameof(OrdersDetails.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn> <GridColumn Field=@nameof(OrdersDetails.CustomerID) HeaderText="Customer ID" Width="150"></GridColumn> <GridColumn Field=@nameof(OrdersDetails.OrderDate) HeaderText="Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn> <GridColumn Field=@nameof(OrdersDetails.Freight) Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn> <GridColumn Field=@nameof(OrdersDetails.ShipCountry) HeaderText="Ship Country" Width="150"></GridColumn> </GridColumns> </SfGrid> </ContentTemplate> </DashboardLayoutPanel> <DashboardLayoutPanel Id="BottomPanel" Column=0 Row=33 SizeX=12 SizeY=1> <ContentTemplate><div>1</div></ContentTemplate> </DashboardLayoutPanel> </DashboardLayoutPanels> </SfDashboardLayout> @code { ... ... |
Desktop | Mobile |
Regards,
Prasanth Madhaiyan.
Attachment: BlazorApp1_974c89a5.zip
Thanks Prasanth. Really appreciate your effort. And sorry, I was off work for last few days and hence could not check your answer.
But, I am not able to run your zip file since it uses net9.0, whereas I use net8.0. I tried converting project to net8.0, but keep getting some runtime errors.
Can you please convert same project to net8.0, syncfusion 26.2.8 and reshare. Thanks.
Regards,
Prasanth Madhaiyan.
Attachment: BlazorSample_35917bde.zip
Hi Prasanth,
Yes, your sample code is working and bottom panel is not overlapping.
I also managed to solve responsive layout issue with combination of -
- MediaQuery="max-width:300px" for SfDashboardLayout , effectively disabling default responsive behavour of dashboard panels
- CellAspectRatio for SfDashboardLayout to control height of panels for small device
- further fine tuning by getting device width using Javascript code, and then using that width to dynamically change number of records in a grid by setting GridPageSettings PageSize value (if else condition using width)
Regards,
Prasanth Madhaiyan.
- 10 Replies
- 2 Participants
-
SM Sandip Mane
- Apr 29, 2025 07:08 AM UTC
- May 16, 2025 06:36 AM UTC