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

How to make a RadGridView select a row that is added by the user.

3 Answers 163 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David Schwartz
Top achievements
Rank 1
David Schwartz asked on 02 Nov 2009, 10:40 PM

I have a RadGridView which has a row for every employee in the database. Users manage employees using this Grid, so they have the capability to add, modify, and remove rows.

I have been able to use the RowsChanging/Changed events to call the appropriate DAL methods to add/remove the information from the underlying database, but when the user adds a row, the row is immediately sorted by whatever sort the user has chosen, and so it "appears" to disappear. In actuality, it has simply placed itself in the appropriate spot in the list according to the sort function. I would like to hook into an event that occurs when the user finishes adding the row and select the row so that the user can see that it was added successfully and did not disappear.

 

How would I accomplish this?

3 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 05 Nov 2009, 03:29 PM
Hi David Schwartz,

Thank you for writing.

I think that ScrollToRow method could be suitable in your scenario. Please, consider the following code:

void radGridView1_RowsChanged(object sender, GridViewCollectionChangedEventArgs e)
{
    GridViewDataRowInfo addedRow = e.NewItems[0] as GridViewDataRowInfo;   
    this.radGridView1.GridElement.ScrollToRow(addedRow);
}

Write me back if you have any other questions.

All the best,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
David Schwartz
Top achievements
Rank 1
answered on 05 Nov 2009, 07:13 PM
Thanks for the reply. Using your method didn't work, which led me to think that it wasn't the methods that didn't work but that I wasn't using them properly. It seems the issue doesn't lie in choosing the appropriate method (to scroll to the row) but in the fact that I am hitting the enter key after adding the row. This causes the grid to advance the selection (to the first row), and not care about the newly added row. I can prove this by pressing tab instead of enter, and the correct (newly added) row is selected as expected.

As a result, I have created a support ticket (which I probably should have done to begin with) and provided a more detailed description of my situation. It is ticket number 256201 . Thank you for your help.
0
Martin Vasilev
Telerik team
answered on 11 Nov 2009, 09:34 AM
Hi David Schwartz,

You can find the answer to your question in the support ticket that you have created. Since our community may also be interested in the answer, I am posting the link of the knowledge base which will help you in your case: Track Newly Added Data Rows.

Regards,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
David Schwartz
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
David Schwartz
Top achievements
Rank 1
Share this question
or