GridViewCellEventArgs and Filtering

2 posts, 1 answers
  1. erwin
    erwin avatar
    382 posts
    Member since:
    Dec 2006

    Posted 11 Sep 2008 Link to this post

    I have a grid with interactive filtering enabled. If the users doubleclicks on a
    cell I get the GridViewCellEventArgs.RowIndex to access the Row.

    However, when Filtering is active, the RowIndex in the Event does not
    point to the correct Row, when I access the

    RadGridView _grid.Rows[rowIndex].Cells[colName].Value

    The GridViewCellEventArgs.RowIndex seems to point to the unfiltered row
    index, while grid.Rows[] contains only the filtered rows.

    What am I missing?


  2. Answer
    Jack avatar
    2333 posts

    Posted 12 Sep 2008 Link to this post

    Hi erwin,

    Thank you for reporting this issue. Unfortunately, in this specific case the IndexOf method of the RadGridView.MasterGridViewTemplate returns the index before the grid was filtered. We will address it in our upcoming release Q3 2008. I have updated your points.

    You can work around this issue by using the following method:

    public int GetRealIndex(GridViewRowInfo row) 
        GridViewRowInfo[] rows = this.radGridView1.MasterGridViewInfo.Rows; 
        for (int i = 0; i<rows.Length; i++) 
            if (row == rows[i]) 
                return i; 
        return -1; 

    Note, that you should use the RadGridView.CurrentRow property to get the current row inside the CellDoubleClick event instead of the RowIndex.

    I hope this helps. Don't hesitate to contact us if you have other questions.

    Best wishes,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top