GridView SearchRow

5 posts, 1 answers
  1. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 23 Oct 2015 Link to this post

    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​.

  2. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 23 Oct 2015 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 23 Oct 2015 in reply to VLADISLAV Link to this post

    "but when Searchrow finds empty cell in 'searchRow' it throws exception." i mean in SummaryRow
  5. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 26 Oct 2015 Link to this post

    Any solution?
  6. Answer
    Dess
    Admin
    Dess avatar
    1607 posts

    Posted 27 Oct 2015 Link to this post

    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready