We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Grid : Height to fit screenheight automatically

Dear Syncfusion,

is it possible to set the height of the grid to 100% , so it fits the screen vertically ?

Regards,
Gert

5 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team May 28, 2019 11:19 AM UTC

Hi Gert, 
 
Thanks for contacting Syncfusion support. 
 
Query 1: is it possible to set the height of the grid to 100% , so it fits the screen vertically ? 
 
Yes, it is possible to set height of the grid to “100%”. We have prepared a sample where the grid fits the screen vertically. Please refer the below code snippet and sample link. 
 
[Index.razor] 
<EjsGrid id="Grid" DataSource="@gridData" Height="100%" >     
    <GridColumns> 
        <GridColumn Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Right" Width="120"></GridColumn> 
        .   .   .   . 
    </GridColumns> 
</EjsGrid> 
 
 
@functions { 
    public object gridData { get; set; } 
    protected override void OnInit() 
    { 
        gridData = OrdersDetails.GetAllRecords(); 
    } 
} 
 
 
 
Please get back to us for further assistance. 
 
Regards, 
Thavasianand S. 



DG Devware GmbH January 2, 2020 07:01 PM UTC

Hello Thavasianand,

i have a same problem with the DataGrid Blazor Component. I want the Grid height justify with flexbox but the Grid component is over the browser screen with 100%. If i set the height to for example 300px it´s fine but not sizeable.

Have you a solution for DataGrid with display:flex?

Regards

Tibor



VN Vignesh Natarajan Syncfusion Team January 3, 2020 01:22 PM UTC

Hi Devware,  

Greetings from Syncfusion support.  

Query: “Have you a solution for DataGrid with display:flex? 

We understand that you want to render the grid in the flexbox and want the Grid height to be adjusted within the box. If you want to the Grid to be adjusted inside the parent container, then we suggest you to define the height property of EjsGrid with 100% and also define specific height to parent container (flexbox). So that based on the flexbox height, Grid will be adjusted inside it.   

Refer the below code example.  

<div class="flex-container"> 
    <EjsGrid @ref="Grid" Height="100%" Width="100%" DataSource="@Orders" AllowPaging="true"> 
. . . . . . . . . . . ..  
    </EjsGrid> 
</div> 
<style> 
    .flex-container { 
        display: flex; 
        height: 500px; 
        width: 700px;         
    } 
</style> 
@code{ 

Refer our UG documentation for your reference 


Please get back to us with more details if you are facing any issues.  

Regards, 
Vignesh Natarajan.  
 



RG Riley Grant January 4, 2024 05:12 PM UTC

This is not a dynamic solution if you have to set the height of the flex-container.

Is there a way to contain the grid within the confines of the parent flex-container, having no overflow, so that it is vertically responsive without having to set a static height value?



SP Sarveswaran Palani Syncfusion Team January 17, 2024 02:16 AM UTC

Hi Riley,

Based on your query, it seems that you want to set the grid height responsively without specifying a static height. In response to this, we recommend setting the container height dynamically based on the viewport dimensions. To illustrate this approach, we have prepared a sample. Please refer to the attached sample for a clear understanding of this responsive grid height implementation

<div style= "height:50vh;">

    <SfGrid DataSource="@Orders" Height="100%" Width="100%">

        <GridColumns>

            <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>

            <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>

            <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>

            <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>

            <GridColumn Field=@nameof(Order.ShipCountry) HeaderText="Ship Country" Width="150"></GridColumn>

        </GridColumns>

    </SfGrid>

</div>


Sample: https://blazorplayground.syncfusion.com/embed/hXVpNiCnsGrczsoa?appbar=true&editor=true&result=true&errorlist=true&theme=bootstrap5

If still you’re facing an issue or we misunderstood your query, kindly share more details about your requirement precisely to us, based on that we’ll validate and provide further solution ASAP from our end.

Regards,
Sarvesh


Loader.
Live Chat Icon For mobile
Up arrow icon