diff --git a/ej2-asp-core-mvc/code-snippet/grid/search/retrieve-records/razor b/ej2-asp-core-mvc/code-snippet/grid/search/retrieve-records/razor new file mode 100644 index 0000000000..883354e362 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/search/retrieve-records/razor @@ -0,0 +1,27 @@ +
+ @Html.EJS().Button("getSearchedRecords").Content("Get Searched Records").Render() +
+@Html.EJS().Grid("grid").DataSource((IEnumerable)ViewBag.datasource).Height("350px").Columns(col => +{ + col.Field("OrderID").HeaderText("Order ID").Width("160").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).IsPrimaryKey(true).Add(); + col.Field("CustomerID").HeaderText("Customer ID").Width("170").Add(); + col.Field("Freight").HeaderText("Freight").Width("170").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Format("C2").Add(); + col.Field("OrderDate").HeaderText("Order Date").Width("170").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Format("yMd").Add(); +})..AllowPaging().PageSettings(page => { page.PageCount(5);}).Toolbar(new List() { "Search" }).ActionComplete("actionComplete").Render() + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/search/retrieve-records/retrieve-records.cs b/ej2-asp-core-mvc/code-snippet/grid/search/retrieve-records/retrieve-records.cs new file mode 100644 index 0000000000..7ead36b9a5 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/search/retrieve-records/retrieve-records.cs @@ -0,0 +1,6 @@ + public IActionResult Index() + { + var orders = OrdersDetails.GetAllRecords(); + ViewBag.datasource = orders; + return View(); + } \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/search/retrieve-records/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/search/retrieve-records/tagHelper new file mode 100644 index 0000000000..c1addce512 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/search/retrieve-records/tagHelper @@ -0,0 +1,29 @@ +
+ +
+ + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/searching.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/searching.md index 5776a79038..f961e05ce5 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/searching.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/searching.md @@ -254,6 +254,25 @@ The following example demonstrates how to clear the searched records using an ex > You can also clear the searched records by using the clear icon within the search input field. +## Retrieving searched records using a button click + +The Syncfusion Grid allows users to retrieve searched records using an external button. This functionality enables capturing the search text entered in the toolbar and filtering the data accordingly. + +To achieve this, the [actionComplete](../api/grid/#actionComplete) event can be used. This event is triggered when a search action is performed, allowing access to the search text. The captured search string can then be used with the `executeQuery` method of the `DataManager` to retrieve the matching records. + +The following example demonstrates how to retrieve searched records using an external button. + +{% tabs %} +{% highlight razor tabtitle="CSHTML" %} +{% include code-snippet/grid/search/retrieve-records/razor %} +{% endhighlight %} +{% highlight c# tabtitle="retrieve-records.cs" %} +{% include code-snippet/grid/search/retrieve-records/retrieve-records.cs %} +{% endhighlight %} +{% endtabs %} + +![Retrieve searched records](images/search/retrieve-records.png) + ## See also * [How to perform search by using Wildcard and LIKE operator filter](https://ej2.syncfusion.com/aspnetmvc/documentation/grid/filtering/filtering#wildcard-and-like-operator-filter) diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/searching.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/searching.md index f22d72acad..fd639ddc00 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/searching.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/searching.md @@ -255,6 +255,26 @@ The following example demonstrates how to clear the searched records using an ex > You can also clear the searched records by using the clear icon within the search input field. +## Retrieve searched records by external button + +The Syncfusion Grid allows users to retrieve searched records using an external button. This functionality enables capturing the search text entered in the toolbar and filtering the data accordingly. + +To achieve this, the [actionComplete](../api/grid/#actionComplete) event can be used. This event is triggered when a search action is performed, allowing access to the search text. The captured search string can then be used with the `executeQuery` method of the `DataManager` to retrieve the matching records. + +The following example demonstrates how to retrieve searched records using an external button: + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/search/retrieve-records/tagHelper %} +{% endhighlight %} + +{% highlight c# tabtitle="retrieve-records.cs" %} +{% include code-snippet/grid/search/retrieve-records/retrieve-records.cs %} +{% endhighlight %} +{% endtabs %} + +![Retrieve searched records](images/search/retrieve-records.png) + ## See also * [How to perform search by using Wildcard and LIKE operator filter](https://ej2.syncfusion.com/aspnetcore/documentation/grid/filtering/filtering#wildcard-and-like-operator-filter) diff --git a/ej2-asp-core-mvc/grid/images/search/retrieve-records.png b/ej2-asp-core-mvc/grid/images/search/retrieve-records.png new file mode 100644 index 0000000000..5fcfc3da1d Binary files /dev/null and b/ej2-asp-core-mvc/grid/images/search/retrieve-records.png differ