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

GridViewCellEventArgs and Filtering

1 Answer 140 Views
GridView
This is a migrated thread and some comments may be shown as answers.
erwin
Top achievements
Rank 1
Veteran
Iron
erwin asked on 11 Sep 2008, 09:33 PM

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?

2008Q2Sp1

1 Answer, 1 is accepted

Sort by
0
Accepted
Jack
Telerik team
answered on 12 Sep 2008, 04:23 PM
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,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
erwin
Top achievements
Rank 1
Veteran
Iron
Answers by
Jack
Telerik team
Share this question
or