From 1d6701c424fe057abf6caeb2f8e7c738759d0765 Mon Sep 17 00:00:00 2001 From: vikramsundarajan <129823420+vikramsundarajan@users.noreply.github.com> Date: Wed, 19 Feb 2025 12:42:24 +0530 Subject: [PATCH 1/2] Added the topic of Set different locale for two Grids in same page --- .../two-localization/localization.cs | 6 +++ .../grid/globalization/two-localization/razor | 42 ++++++++++++++++++ .../globalization/two-localization/tagHelper | 44 +++++++++++++++++++ .../grid/EJ2_ASP.MVC/global-local.md | 17 +++++++ .../grid/EJ2_ASP.NETCORE/global-local.md | 17 +++++++ 5 files changed, 126 insertions(+) create mode 100644 ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/localization.cs create mode 100644 ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/razor create mode 100644 ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/tagHelper diff --git a/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/localization.cs b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/localization.cs new file mode 100644 index 0000000000..c728c26fcc --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/localization.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var orders = OrderDetails.GetAllRecords(); + ViewBag.datasource = orders; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/razor b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/razor new file mode 100644 index 0000000000..32028915a9 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/razor @@ -0,0 +1,42 @@ +@Html.EJS().Grid("deGrid").DataSource((IEnumerable)ViewBag.datasource).Columns(col => + { + col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width("120").Add(); + col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); + col.Field("ShipName").HeaderText("Ship Name").Width("150").Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add(); + + }).AllowPaging().AllowGrouping().Locale("de-DE").PageSettings(page => page.PageSize(6)).Render(); + + @Html.EJS().Grid("enGrid").DataSource((IEnumerable)ViewBag.datasource).Columns(col => + { + col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width("120").Add(); + col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); + col.Field("ShipName").HeaderText("Ship Name").Width("150").Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add(); + + }).AllowPaging().AllowGrouping().Locale("en").PageSettings(page => page.PageSize(6)).Render() + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/tagHelper new file mode 100644 index 0000000000..3d91c013ed --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/tagHelper @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/global-local.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/global-local.md index 8d24edf1f6..a636df4e5b 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/global-local.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/global-local.md @@ -295,6 +295,23 @@ To switch to the **French** culture and set the currency code as **EUR**, you ca ![Globalization-Switch-Culture](images/globalization/switch-localization.gif) +### Set different locale for two Grids in same page + +The Syncfusion Grid allows you to use different locales for multiple Grids on the same page. You can achieve this by setting the [locale](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_Locale) property for each Grid individually. + +In the following example, the first Grid is configured to use the French **de-DE** locale. This is achieved by setting the locale property to **de-DE** and loading the French translation object using the **L10n.load** function from the **ej2-base** module. For the second Grid, the locale property is set to **en-US**, which applies the default English locale. + +This setup demonstrates how to display/apply different locale texts for each Grid on the same page by configuring the [locale](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_Locale) property individually and loading the necessary translations. + +{% tabs %} +{% highlight razor tabtitle="CSHTML" %} +{% include code-snippet/grid/globalization/two-localization/razor %} +{% endhighlight %} +{% highlight c# tabtitle="Localization.cs" %} +{% include code-snippet/grid/globalization/two-localization/localization.cs %} +{% endhighlight %} +{% endtabs %} + ## Internationalization The Internationalization library in the Syncfusion ASP.NET MVC Grid provides a localized display of number, date, and time values in the Grid control based on the preferred language and region. diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/global-local.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/global-local.md index 552cb5a5d2..5b6113f862 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/global-local.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/global-local.md @@ -295,6 +295,23 @@ To switch to the **French** culture and set the currency code as **EUR**, you ca ![Globalization-Switch-Culture](images/globalization/switch-localization.gif) +### Set different locale for two Grids in same page + +The Syncfusion Grid allows you to use different locales for multiple Grids on the same page. You can achieve this by setting the [locale](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_Locale) property for each Grid individually. + +In the following example, the first Grid is configured to use the French **de-DE** locale. This is achieved by setting the locale property to **de-DE** and loading the French translation object using the **L10n.load** function from the **ej2-base** module. For the second Grid, the locale property is set to **en-US**, which applies the default English locale. + +This setup demonstrates how to display/apply different locale texts for each Grid on the same page by configuring the [locale](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_Locale) property individually and loading the necessary translations. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/globalization/two-localization/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="Localization.cs" %} +{% include code-snippet/grid/globalization/two-localization/localization.cs %} +{% endhighlight %} +{% endtabs %} + ## Internationalization The Internationalization library in the Syncfusion ASP.NET Core Grid provides a localized display of number, date, and time values in the Grid control based on the preferred language and region. From 914d8027330c5d464d8420f0a4f06b949e728c43 Mon Sep 17 00:00:00 2001 From: vikramsundarajan <129823420+vikramsundarajan@users.noreply.github.com> Date: Sun, 23 Mar 2025 21:08:25 +0530 Subject: [PATCH 2/2] 940676: Changed the content and code snippet --- .../grid/globalization/two-localization/razor | 209 ++++++++++++++---- .../globalization/two-localization/tagHelper | 176 +++++++++++++-- .../grid/EJ2_ASP.MVC/global-local.md | 7 +- .../grid/EJ2_ASP.NETCORE/global-local.md | 7 +- 4 files changed, 330 insertions(+), 69 deletions(-) diff --git a/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/razor b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/razor index 32028915a9..18234cb923 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/razor +++ b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/razor @@ -1,42 +1,169 @@ -@Html.EJS().Grid("deGrid").DataSource((IEnumerable)ViewBag.datasource).Columns(col => - { - col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width("120").Add(); - col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); - col.Field("ShipName").HeaderText("Ship Name").Width("150").Add(); - col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add(); - - }).AllowPaging().AllowGrouping().Locale("de-DE").PageSettings(page => page.PageSize(6)).Render(); - - @Html.EJS().Grid("enGrid").DataSource((IEnumerable)ViewBag.datasource).Columns(col => - { - col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width("120").Add(); - col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); - col.Field("ShipName").HeaderText("Ship Name").Width("150").Add(); - col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add(); - - }).AllowPaging().AllowGrouping().Locale("en").PageSettings(page => page.PageSize(6)).Render() - - \ No newline at end of file + } + }); + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/tagHelper index 3d91c013ed..1eee8080d2 100644 --- a/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/tagHelper +++ b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/tagHelper @@ -1,17 +1,15 @@ - - + - + - - + - + @@ -19,25 +17,159 @@