Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Blazor.Grid" Version="20.2.0.38" />
<PackageReference Include="Syncfusion.Blazor" Version="20.4.0.48" />
</ItemGroup>

</Project>
53 changes: 43 additions & 10 deletions Grid-AdaptiveLayout/Grid-AdaptiveLayout/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -1,18 +1,51 @@
@page "/counter"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add intro title in page as

Enable/Disable DataGrid Adaptive UI using Media Query Component

<PageTitle>Counter</PageTitle>
@using Syncfusion.Blazor
@using Syncfusion.Blazor.Grids

<h1>Counter</h1>

<p role="status">Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
<div style="position:relative; min-height: 500px;">
<SfMediaQuery @bind-ActiveBreakPoint="activeBreakpoint"></SfMediaQuery>
@if (activeBreakpoint == "Small")
{
isAdaptive = true;
}
else
{
isAdaptive = false;
}
<SfGrid DataSource="@Orders" AllowSorting="true" AllowFiltering="true" EnableAdaptiveUI="@isAdaptive" RowRenderingMode="RowDirection.Vertical" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update", "Search" })" AllowPaging="true">
<GridFilterSettings Type="@FilterType.Excel"></GridFilterSettings>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Dialog"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" Width="80" ValidationRules="@(new ValidationRules{ Required= true })"></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" Width="130"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
</div>

@code {
private int currentCount = 0;
public List<Order>? Orders { get; set; }
private string? activeBreakpoint { get; set; }
private bool isAdaptive { get; set; }

protected override void OnInitialized()
{
Orders = Enumerable.Range(1, 75).Select(x => new Order()
{
OrderID = 1000 + x,
CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],
Freight = 2.1 * x,
OrderDate = DateTime.Now.AddDays(-x),
}).ToList();
}

private void IncrementCount()
public class Order
{
currentCount++;
public int? OrderID { get; set; }
public string? CustomerID { get; set; }
public DateTime? OrderDate { get; set; }
public double? Freight { get; set; }
}
}
}
4 changes: 2 additions & 2 deletions Grid-AdaptiveLayout/Grid-AdaptiveLayout/Pages/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
<link href="Grid-AdaptiveLayout.styles.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/blazor/20.2.38/styles/fluent.css" rel="stylesheet" />
<script src="https://cdn.syncfusion.com/blazor/20.2.38/syncfusion-blazor.min.js" type="text/javascript"></script>
<link href="https://cdn.syncfusion.com/blazor/20.4.48/styles/fluent.css" rel="stylesheet" />
<script src="https://cdn.syncfusion.com/blazor/20.4.48/syncfusion-blazor.min.js" type="text/javascript"></script>
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
</head>
<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<span class="oi oi-plus" aria-hidden="true"></span> Counter
<span class="oi oi-plus" aria-hidden="true"></span> AdaptiveUI with SfMediaQuery
Copy link
Contributor

@syncsiva syncsiva Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataGrid Adaptive UI using Media Query

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the side bar name as DataGrid Adaptive UI using Media Query
9b44168

</NavLink>
</div>
<div class="nav-item px-3">
Expand Down