From 886a4cd33c0420eb4232ee19578d1c543f189032 Mon Sep 17 00:00:00 2001 From: Vinitha Balasubramanian Date: Thu, 20 Nov 2025 13:58:58 +0530 Subject: [PATCH] 989596: Included partial selection topic - Hotfix --- .../prevent-checkbox-selection/checkbox.cs | 5 +++++ .../prevent-checkbox-selection/razor | 16 +++++++++++++++ .../prevent-checkbox-selection/tagHelper | 20 +++++++++++++++++++ .../selection/check-box-selection.md | 17 ++++++++++++++++ .../selection/check-box-selection.md | 17 ++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 ej2-asp-core-mvc/code-snippet/grid/selection/prevent-checkbox-selection/checkbox.cs create mode 100644 ej2-asp-core-mvc/code-snippet/grid/selection/prevent-checkbox-selection/razor create mode 100644 ej2-asp-core-mvc/code-snippet/grid/selection/prevent-checkbox-selection/tagHelper diff --git a/ej2-asp-core-mvc/code-snippet/grid/selection/prevent-checkbox-selection/checkbox.cs b/ej2-asp-core-mvc/code-snippet/grid/selection/prevent-checkbox-selection/checkbox.cs new file mode 100644 index 0000000000..63e5ad554e --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/selection/prevent-checkbox-selection/checkbox.cs @@ -0,0 +1,5 @@ +public IActionResult Index() +{ + ViewBag.dataSource = OrderDetails.GetAllRecords(); + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/selection/prevent-checkbox-selection/razor b/ej2-asp-core-mvc/code-snippet/grid/selection/prevent-checkbox-selection/razor new file mode 100644 index 0000000000..d7563df6e6 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/selection/prevent-checkbox-selection/razor @@ -0,0 +1,16 @@ +Html.EJS().Grid("grid").DataSource((IEnumerable)ViewBag.dataSource).Columns(col => +{ + col.Type("checkbox").Width("40").Add(); + col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("110").ValidationRules(new { required = true }).Add(); + col.Field("CustomerName").HeaderText("Customer Name").Width("120").ValidationRules(new { required = true }).Add(); + col.Field("Product").HeaderText("Product").Width("110").EditType("dropdownedit").Add(); + col.Field("Amount").HeaderText("Amount").Width("110").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).ValidationRules(new { required = true }).Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("110").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).EditType("datepickeredit").Format("yMd").Add(); + col.Field("Status").HeaderText("Status").Width("110").EditType("dropdownedit").Add(); +}).AllowPaging().AllowSorting().AllowFiltering().Toolbar(new List() { "Edit", "Update", "Cancel" }).FilterSettings(filter => filter.Type(Syncfusion.EJ2.Grids.FilterType.Excel)).EditSettings(edit => {edit.AllowEditing(true).AllowAdding(false).AllowDeleting(false).Mode(Syncfusion.EJ2.Grids.EditMode.Normal);}).SelectionSettings(select => select.PersistSelection(true)).IsRowSelectable("isRowSelectable").Render() + + diff --git a/ej2-asp-core-mvc/code-snippet/grid/selection/prevent-checkbox-selection/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/selection/prevent-checkbox-selection/tagHelper new file mode 100644 index 0000000000..5ddd48af3a --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/selection/prevent-checkbox-selection/tagHelper @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/selection/check-box-selection.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/selection/check-box-selection.md index eacd5070d8..81e991bc17 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/selection/check-box-selection.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/selection/check-box-selection.md @@ -88,6 +88,23 @@ In the following sample, the selection of specific rows has been prevented based ![Prevent specific rows from being selected in checkbox selection](../images/selection/checkbox-prevent.gif) +## Partial selection using isRowSelectable + +The `isRowSelectable` callback in Syncfusion's EJ2 Grid allows control over which rows users can select. It uses a simple callback that runs before the grid loads the data. This callback checks each row data and returns **true** if the row can be selected, or **false** for non-selectable rows. + +For local data, the callback checks all items just once when the grid first loads. For remote data, it only checks the rows shown on the current page when the grid first appears. It re-checks them every time an action occurs, such as changing pages, filtering, or sorting. + +In the example below, it prevents selection of rows with canceled orders. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/selection/prevent-checkbox-selection/razor %} +{% endhighlight %} +{% highlight c# tabtitle="checkbox.cs" %} +{% include code-snippet/grid/selection/prevent-checkbox-selection/checkbox.cs %} +{% endhighlight %} +{% endtabs %} + ## How to select single row in checkbox selection mode The ASP.NET MVC Grid allows you to select only one row at a time within the Grid. This feature is particularly useful when you want to ensure that only a single row is selected, and any previous selections are cleared when a new row is selected. diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/selection/check-box-selection.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/selection/check-box-selection.md index 7096014c1f..88e46224d4 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/selection/check-box-selection.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/selection/check-box-selection.md @@ -88,6 +88,23 @@ In the following sample, the selection of specific rows has been prevented based ![Prevent specific rows from being selected in checkbox selection](../images/selection/checkbox-prevent.gif) +## Partial selection using isRowSelectable + +The `isRowSelectable` callback in Syncfusion's EJ2 Grid allows control over which rows users can select. It uses a simple callback that runs before the grid loads the data. This callback checks each row data and returns **true** if the row can be selected, or **false** for non-selectable rows. + +For local data, the callback checks all items just once when the grid first loads. For remote data, it only checks the rows shown on the current page when the grid first appears. It re-checks them every time an action occurs, such as changing pages, filtering, or sorting. + +In the example below, it prevents selection of rows with canceled orders. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/selection/prevent-checkbox-selection/tagHelper %} +{% endhighlight %} +{% highlight c# tabtitle="checkbox.cs" %} +{% include code-snippet/grid/selection/prevent-checkbox-selection/checkbox.cs %} +{% endhighlight %} +{% endtabs %} + ## How to select single row in checkbox selection mode The ASP.NET CORE Grid allows you to select only one row at a time within the Grid. This feature is particularly useful when you want to ensure that only a single row is selected, and any previous selections are cleared when a new row is selected.