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

Old RowIndex Problem in RadGrid with FilteringLet me specific here..................... I have a grid with interactive filtering enabled. If the users clicks on a button which is placed inside the gr

5 Answers 176 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kamesh Gupta
Top achievements
Rank 1
Kamesh Gupta asked on 05 Apr 2010, 01:22 PM
Let me specific here.....................

I have a grid with interactive filtering enabled. If the users clicks on a
button which is placed inside the grid to edit the record on another form, I get the GridViewInfo.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

index = RadGridView1.CurrentRow.GridViewInfo.CurrentIndex;

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

What shall i do...I am using C# and Telerik Windows Q1 2009

5 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 08 Apr 2010, 04:27 PM
Hello Kamesh Gupta,

Thank you for writing.

Indeed the CurentIndex property is not a good way to save the row reference, because the Rows collection is dynamically changing when filtering, sorting, grouping etc. Instead, I recommend you to create GridViewRowInfo type and reference the desired row for post-processing:
 
GridViewRowInfo row = this.radGridView1.CurrentRow;

Let me know if you have any other questions.

Regards,
Martin Vasilev
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Jigar
Top achievements
Rank 1
answered on 16 Oct 2012, 09:28 AM
I have a grid with filtering enabled. if user filters, I get the GridViewInfo.RowIndex to access the Row.

but the RowIndex in the Event does not point to the correct Row.

The GridViewInfo.RowIndex seems to point to the unfiltered rowindex.

below is my code 

GridViewRowInfo row = this.grdList.CurrentRow;
int rowIndex = row.Index;

string programcode = grdList.Rows[rowIndex].Cells[0].Value.ToString();
ProgramDetails ProgramDetails = new ProgramDetails(programcode, "asrun");
ProgramDetails.ShowDialog();


I am using C# and Telerik Windows 2012.2.912.20
 
0
Julian Benkov
Telerik team
answered on 19 Oct 2012, 07:55 AM
Hi Jigar,

GridViewInfo.RowIndex points to the index based on the ChildRows collection of the GridViewTemplate. The ChildRows collection is the current view of the rows after a filtering, grouping and/or sorting operation. The Rows collection points to all data rows of the GridViewTemplate without data operation applied. More information about this topic and the API you can find in our online documentation.

I hope this information is useful. Feel free to ask if you have any additional questions. 

Greetings,
Julian Benkov
the Telerik team
You’ve been asking for it and now it’s time for us to deliver. RadControls for WinForms Q3 2012 release is just around the corner. Sign up for a free webinar to see first all the latest enhancements.
0
Jigar
Top achievements
Rank 1
answered on 19 Oct 2012, 11:24 AM
Hello

ok, one simple question, how do I get rowindex after filter as my below code gives wrong index

GridViewRowInfo row = this.grdList.CurrentRow;
int rowIndex = row.Index;

string programcode = grdList.Rows[rowIndex].Cells[0].Value.ToString();
ProgramDetails ProgramDetails = new ProgramDetails(programcode, "asrun");
ProgramDetails.ShowDialog();

Regards
Jigar Bhatt
0
Julian Benkov
Telerik team
answered on 19 Oct 2012, 03:43 PM
Hi Kamesh,

You must only change the Rows collection with ChildRows collection:
GridViewRowInfo row = this.grdList.CurrentRow;
int rowIndex = row.Index;
 
string programcode = grdList.ChildRows[rowIndex].Cells[0].Value.ToString();
ProgramDetails ProgramDetails = new ProgramDetails(programcode, "asrun");
ProgramDetails.ShowDialog();

I hope this helps. Do not hesitate to contact us if you have further questions or issues.  

Regards,
Julian Benkov
the Telerik team
You’ve been asking for it and now it’s time for us to deliver. RadControls for WinForms Q3 2012 release is just around the corner. Sign up for a free webinar to see first all the latest enhancements.
Tags
GridView
Asked by
Kamesh Gupta
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Jigar
Top achievements
Rank 1
Julian Benkov
Telerik team
Share this question
or