Datagrid Height

Hi,

I use the following code and everything is OK:

  <SfGrid @ref="myGrid" DataSource="@lstUsers" GridLines="GridLine.Both" 

        AllowSorting="true" AllowFiltering="true" AllowResizing="true"

        Height="100%" Width="100%">

</SfGrid>


But when I use the following code, there is a problem that the height of the datagrid is not set correctly and sometimes the scroll bar is not displayed.

 <div role="alert" class="alert alert-primary d-flex justify-content-between " style="margin-top:3p;"></div>

 <SfGrid @ref="myGrid" DataSource="@lstUsers" GridLines="GridLine.Both" 

        AllowSorting="true" AllowFiltering="true" AllowResizing="true"

        Height="100%" Width="100%">

</SfGrid>


I have read the following documunet:

https://blazor.syncfusion.com/documentation/datagrid/scrolling?_ga=2.156862072.218327963.1642223498-73119071.1629792372#responsive-with-parent-container


The problem is that the height of the alert div can be different at runtime and I can not use the mentioned guide


1 Reply

RS Renjith Singh Rajendran Syncfusion Team January 17, 2022 08:45 AM UTC

Hi Sarah, 
 
Greetings from Syncfusion support. 
 
We would like to inform you that the scrollbar will be displayed in the DataGrid when grid’s content exceeds the grid element Width or Height. By default, DataGrid will adapt to the browser (or its parent) element’s width and height. To contain the Grid’s content inside its parent the scroll bars will be rendered.  
 
Grid will be rendered based on its parent div element height and width. So we suggest you to set the height and width based on your requirement for the Grid’s parent div element. In the below documentation we have provided dynamic height and width for Grid’s parent div element so that Grid’s height and width will get adjusted based on calculated value. 
 
As you have contained Grid inside a parent div element(alert), we suggest you to either set a static height or dynamically calculate height using the above suggested calc codes. Only based on the parent div element’s height and width the Grid will be rendered. 
 
Regards, 
Renjith R 


Loader.
Up arrow icon