This is a migrated thread and some comments may be shown as answers.

GridView SearchRow

4 Answers 170 Views
GridView
This is a migrated thread and some comments may be shown as answers.
VLADISLAV
Top achievements
Rank 1
VLADISLAV asked on 23 Oct 2015, 06:04 AM

using this code  part to exclude summaryRows from Search loop. 

#code

public class SearchRow : GridViewSearchRowInfo
{
    public SearchRow(GridViewInfo viewInfo) : base(viewInfo)
    {
    }
 
    protected override bool MatchesSearchCriteria(string searchCriteria, GridViewRowInfo row, GridViewColumn col)
    {
        if (row is GridViewSummaryRowInfo)
        {
            return false;
        }
        return base.MatchesSearchCriteria(searchCriteria, row, col);
    }
}
 
private void radGridView1_CreateRowInfo(object sender, GridViewCreateRowInfoEventArgs e)
{
    if (e.RowInfo is GridViewSearchRowInfo)
    {
        e.RowInfo = new SearchRow(e.ViewInfo);
    }
}

#code

And now i cant itterate through search results, i can only choose the first one and the last one​.

4 Answers, 1 is accepted

Sort by
0
VLADISLAV
Top achievements
Rank 1
answered on 23 Oct 2015, 06:20 AM
Without this code everythng works great, i mean i can iterate through search results, but when Searchrow finds empty cell in searchRow it throws exception.
0
VLADISLAV
Top achievements
Rank 1
answered on 23 Oct 2015, 06:25 AM
"but when Searchrow finds empty cell in 'searchRow' it throws exception." i mean in SummaryRow
0
VLADISLAV
Top achievements
Rank 1
answered on 27 Oct 2015, 04:18 AM
Any solution?
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 27 Oct 2015, 10:22 AM
Hello Vladislav,

Thank you for writing.

Following the provided information, I was unable to replicate the error you are facing. Could you please specify the exact steps how to reproduce the problem? Alternatively, you can open a support ticket with a sample project so I can investigate the precise case.

Note that you can access the search results in the RadGridView.MasterView.TableSearchRow.SearchProgressChanged event. Here is a sample code snippet:
public Form1()
{
    InitializeComponent();
 
    this.radGridView1.AllowSearchRow = true;           
    this.radGridView1.DataSource = this.ordersBindingSource;
 
    GridViewSummaryItem summaryItem = new GridViewSummaryItem();
    summaryItem.Name = "ShipName";
    summaryItem.Aggregate = GridAggregateFunction.Count;           
    GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem();
    summaryRowItem.Add(summaryItem);
    this.radGridView1.SummaryRowsTop.Add(summaryRowItem);
 
    this.radGridView1.MasterView.TableSearchRow.InitialSearchResultsTreshold = 0;
    this.radGridView1.MasterView.TableSearchRow.SearchProgressChanged += TableSearchRow_SearchProgressChanged;
}
 
private void TableSearchRow_SearchProgressChanged(object sender, SearchProgressChangedEventArgs e)
{
    if (e.SearchFinished == false && e.SearchCriteria != null && e.SearchCriteria != string.Empty)
    {
        Console.WriteLine("Search results: " + e.Cells.Count);
        foreach (GridSearchResultCellInfo c in e.Cells)
        {
            Console.WriteLine(c.RowInfo.Cells[c.ColumnInfo.Name].Value);
        }
    }
}
 
private void Form1_Load(object sender, EventArgs e)
{
    this.ordersTableAdapter.Fill(this.nwindDataSet.Orders);
}
 
public class SearchRow : GridViewSearchRowInfo
{
    public SearchRow(GridViewInfo viewInfo) : base(viewInfo)
    {
    }
 
    protected override bool MatchesSearchCriteria(string searchCriteria, GridViewRowInfo row, GridViewColumn col)
    {
        if (row is GridViewSummaryRowInfo)
        {
            return false;
        }
        return base.MatchesSearchCriteria(searchCriteria, row, col);
    }
}
 
private void radGridView1_CreateRowInfo(object sender, GridViewCreateRowInfoEventArgs e)
{
    if (e.RowInfo is GridViewSearchRowInfo)
    {
        e.RowInfo = new SearchRow(e.ViewInfo);
    }
}

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
VLADISLAV
Top achievements
Rank 1
Answers by
VLADISLAV
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or