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

Focus a Specific Row

4 Answers 77 Views
GridView
This is a migrated thread and some comments may be shown as answers.
WILLIAM
Top achievements
Rank 1
WILLIAM asked on 07 May 2013, 10:11 PM
I'm trying to focus a specific row.  I've searched this forum and for every question on how to do this, there is a different answer on how to do it; and I have yet to find one that works.

I've tried grid.GetRowForItem() which takes a parameter of object called item.  I've tried passing in both the grid.CurrentItem and grid.SelectedItem, but this method always returns null.  What am I supposed to pass in as the parameter?  If I were to get a row back, I think I could call row.Focus().

I am also setting grid.CurrentItem and grid.SelectedItem to my new object and then calling grid.ScrollIntoView(item).  The scrolling into view is working.  

There seems to be two different indicators for a focused row.  There is one where the record is gray, and one where the record is yellow.  I believe grid.SelectedItem is working and setting the correct row to the grayish color.  However, I have to click into the row in order for it to actually be selected.

I have also tried setting grid.IsSynchronizedWithCurrentItem = true, but this has no effect.

How do I do this?

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 08 May 2013, 02:43 AM
Hello William,

Basically, CurrentItem is the one holding the focus, while the SelectedItem is the one being selected. The two of them may or may not coincide. Selected state has two substates - selected focused (the yellowish) and selected ufocused (the greyish -  when the grid does not have the focus).
Setting IsSynchronizedWithCurrentItem will mean that selected item is updated once a particular row is focused. 
What is the exact behavior that you want to ge ? Do you want to insert new item in the source and have it focused ? 

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
WILLIAM
Top achievements
Rank 1
answered on 08 May 2013, 03:08 PM
Hi Maya,

Thanks for the clarification and I may have most of it working.  The unselected focus is being set properly, and it is scrolled into view.  I need to set the selected focus on that row as well.  This should fire the GridView.SelectionChanged event.  (this is the main goal, to have the GridView.SelectionChanged event without the user having to click in the row.

Thanks again!
0
WILLIAM
Top achievements
Rank 1
answered on 08 May 2013, 06:03 PM
Hi Maya,

I wanted to let you know that I figured out a way to accomplish this task.  Thanks again for your help!!
0
Maya
Telerik team
answered on 08 May 2013, 09:03 PM
Hi William,

I really happy to see that you have resolved the issue. Let me know if I could be of any further help. 

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
WILLIAM
Top achievements
Rank 1
Answers by
Maya
Telerik team
WILLIAM
Top achievements
Rank 1
Share this question
or