<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();
}
}
|
<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{ |
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?
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