Hello !
Please tell me how can I find first occurrence of the inserted text into all the columns of the grid.
In case the text is found, I want the entire row to be selected even the selection is on another page of the grid.
Otherwise a message must tell "the text is not found !
Thank you very much !
The razor page file is attached.
@page "/test"
@using Syncfusion.Blazor.Grids
@using Syncfusion.Blazor.Inputs
<h2>Test : Search in grid </h2>
<h3> Please tell me how can I search first occurrence of the inserted text into all the columns of the grid</h3>
<h3> In case the text is found, I want the entire row to be selected </h3>
<h3> Otherwise a message must tell "the text is not found !"</h3>
<SfTextBox Value="@TextToSearch" Placeholder="Insert text..."></SfTextBox>
<button @onclick="@SearchTextInGrid">Search Text in Grid</button>
<SfGrid DataSource="@Orders"></SfGrid>
@code{
public 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; }
}
public string TextToSearch { get; set; } = "";
public void SearchTextInGrid()
{
}
}
|
<SfTextBox @bind-Value="@TextToSearch" Placeholder="Insert text..."></SfTextBox>
<button @onclick="@SearchTextInGrid">Search Text in Grid</button>
<SfGrid @ref="Grid" DataSource="@Orders"></SfGrid>
@code{
public List<Order> Orders { get; set; }
SfGrid<Order> Grid { get; set; }
public string TextToSearch { get; set; } = "";
public void SearchTextInGrid()
{
if (TextToSearch != "")
{
Grid.SearchAsync(TextToSearch);
}
//show custom dialog here as per your requirement for no text found
}
|
Thank you for your help !
But I think you did not understand what I want...
I don't want to filter the grid based on the TextToSearch value.
I just want to search in every column of the grid the first occurrence of the TextToSearch value. THE GRID MUST NOT BE FILTERED ! The data in the grid must remain as it was at the beginning.
I just want to select the first row of the grid which contains the TextToSearch value in any of the columns.
I want something like using a normal search in a file in Notepad with CTRL+F.
Thank You Very Much !