Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7f9dd39
855861: Added subtopics for blazor media query.
VigneshwaranGovindharajan Dec 28, 2023
1ab7611
855861: Updated review concerns for blazor media query.
VigneshwaranGovindharajan Jan 2, 2024
b60174d
855861: Updated review concerns for blazor media query.
VigneshwaranGovindharajan Jan 2, 2024
8bb6835
855861: Updated review concerns for blazor media query.
VigneshwaranGovindharajan Jan 4, 2024
bfda6b4
855861: Updated review concerns for blazor media query.
VigneshwaranGovindharajan Jan 10, 2024
03e1572
855861: Updated review concerns.
VigneshwaranGovindharajan Jan 12, 2024
b29fe30
855861: Updated gif images.
VigneshwaranGovindharajan Jan 12, 2024
9d001f6
855861: compressed gif image size.
VigneshwaranGovindharajan Jan 12, 2024
e1279b7
855861: compressed gif image size.
VigneshwaranGovindharajan Jan 12, 2024
5e72434
855861: compressed gif image size.
VigneshwaranGovindharajan Jan 12, 2024
6fb2693
855861: Updated gif images and sample.
VigneshwaranGovindharajan Jan 16, 2024
dd49c9f
855861: Updated gif images and sample.
VigneshwaranGovindharajan Jan 16, 2024
97edae1
855861: Re-framed the description.
IndrajithSrinivasan Jan 19, 2024
a06f213
855861: Re-framed the description.
IndrajithSrinivasan Jan 19, 2024
ad7482c
855861: Updated gif images.
VigneshwaranGovindharajan Jan 22, 2024
a921420
855861: Updated gif images.
VigneshwaranGovindharajan Jan 22, 2024
28f349a
855861: Updated review concerns.
VigneshwaranGovindharajan Jan 22, 2024
2707760
855861: Modified Media Query UG
silambarasani Jan 23, 2024
d7f499e
855861: Updated review concerns.
VigneshwaranGovindharajan Jan 24, 2024
5118aef
855861: Updated the descriptions
IndrajithSrinivasan Jan 24, 2024
5607c51
855861: Updated integration sample.
VigneshwaranGovindharajan Jan 29, 2024
6a64227
855861: Updated integration sample.
VigneshwaranGovindharajan Jan 31, 2024
49f6514
855861: Updated review concerns.
VigneshwaranGovindharajan Jan 31, 2024
183143c
855861: Updated gif image.
VigneshwaranGovindharajan Feb 1, 2024
667fb34
855861: Updated gif image.
VigneshwaranGovindharajan Feb 1, 2024
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 85 additions & 0 deletions blazor/media-query/media-query-integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
layout: post
title: Media Query component Integration with other components | Syncfusion
description: Checkout and learn here all about how to integrate the Media Query with other component like Chart and much more details.
platform: Blazor
control: Media Query
documentation: ug
---

# Media Query with other components integration

The Blazor Media Query component enhances the responsiveness of web application, allowing you to perform conditional rendering or styling to achieve a dynamic UI adpatable for various screen sizes.

In the following code example, showcasing the Data Grid to demonstrate the dynamic updating of adaptive functionalities based on the matched media breakpoint using [ActiveBreakpoint](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfMediaQuery.html#Syncfusion_Blazor_SfMediaQuery_ActiveBreakpoint) property.

```cshtml

@using Syncfusion.Blazor
@using Syncfusion.Blazor.Grids

<SfMediaQuery @bind-ActiveBreakPoint="activeBreakpoint"></SfMediaQuery>

Active media name: <b>@activeBreakpoint</b>

@{
var renderingMode = RowDirection.Horizontal;
var enableAdaptiveUIMode = false;
var containerHeight = "100%";

if (activeBreakpoint == "Small")
{
enableAdaptiveUIMode = true;
renderingMode = RowDirection.Vertical;
containerHeight = "600px";
}
else if (activeBreakpoint == "Medium")
{
enableAdaptiveUIMode = true;
}
else
{
enableAdaptiveUIMode = false;
}
}

<div style="position:relative; height: @containerHeight;">
<SfGrid DataSource="@orders" EnableAdaptiveUI="@enableAdaptiveUIMode" RowRenderingMode="@renderingMode" AllowSorting="true" AllowFiltering="true" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update", "Search" })" Height="100%" Width="100%">
<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"></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2"></GridColumn>
</GridColumns>
</SfGrid>
</div>

@code {
private string activeBreakpoint { get; set; }
private List<Order> orders { 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();
}

public class Order
{
public int? OrderID { get; set; }
public string CustomerID { get; set; }
public DateTime? OrderDate { get; set; }
public double? Freight { get; set; }
}
}

```

![Blazor Media Query integration in Grid](images/blazor-media-query-with-grid.gif)
86 changes: 86 additions & 0 deletions blazor/media-query/media-query-reusable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
layout: post
title: Reuse of Blazor Media Query component | Syncfusion
description: Checkout and learn here all about how to use the Media Query component at the global level reuse on all pages and much more.
platform: Blazor
control: Media Query
documentation: ug
---

# Global level reuse of Blazor Media Query component

You can globally reuse the Media Query component in any `razor` pages within web application to achieve a more flexible and responsive layout design.

Define the Media Query component along with layout `Body` property within the `CascadingValue` component in **MainLayout.razor** page.

{% tabs %}
{% highlight razor %}

@inherits LayoutComponentBase

<div class="page">
<div class="sidebar">
<NavMenu />
</div>
<main>
<div class="top-row px-4">
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
</div>
<article class="content px-4">
<CascadingValue Value="@activeBreakPoint">
<SfMediaQuery @bind-ActiveBreakPoint="activeBreakPoint"></SfMediaQuery>
@Body
</CascadingValue>
</article>
</main>
</div>

@code {
[Parameter]
public string activeBreakPoint { get; set; }
}

{% endhighlight %}
{% endtabs %}

If you are using .NET 8, configure the `@rendermode` in the `<body>` section of the **~/Components/App.razor** file, as shown below:

```html
<body>
....
<Routes @rendermode="InteractiveServer" />
</body>
```

In the below example, the `activeBreakPoint` was accessed in the **Home.razor** and **Counter.razor** files.

{% tabs %}
{% highlight C# tabtitle="Home" hl_lines="3 10" %}

The active breakpoint is @activeBreakPointValue
<br/><br/>
<h5>Home Page</h5>

@code {
[CascadingParameter]
public string activeBreakPointValue { get; set; }
}
....

{% endhighlight %}
{% highlight C# tabtitle="Counter" hl_lines="3 11" %}

The active breakpoint is @activeBreakPointValue
<br /><br />
<h5>Counter Page</h5>

@code {
[CascadingParameter]
public string activeBreakPointValue { get; set; }
}
....

{% endhighlight %}
{% endtabs %}

![Reusable Blazor Media Query Component](images/blazor-media-query-reusable.gif)