13 Answers, 1 is accepted
0
Accepted

Inquisitor Jax
Top achievements
Rank 1
answered on 03 Sep 2009, 02:27 PM
try
if (grid.Records.count > 0)
{
grid.Records[0].IsSelected = true;
}
if (grid.Records.count > 0)
{
grid.Records[0].IsSelected = true;
}
0

Srini
Top achievements
Rank 1
answered on 03 Sep 2009, 02:59 PM
Thank You Jax,
I got it.
I got it.
0

Michał Polak
Top achievements
Rank 1
answered on 17 Feb 2010, 07:30 PM
Current version of RadGridView doesn't have Records collection, how can I select first row now?
0
Hi,
You can assign SelectedItem to desired object. You can check our online demos for more info about latest techniques.
All the best,
Vlad
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.
You can assign SelectedItem to desired object. You can check our online demos for more info about latest techniques.
All the best,
Vlad
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

Michał Polak
Top achievements
Rank 1
answered on 18 Feb 2010, 01:16 PM
Yes but how can I identify which object is first i grid? I'm binding ItemsSource to ICollection, but taking first object from ICollection doesn't work, the order is different after sorting the grid.
0
Hi Michał Polak,
Best wishes,
Milan
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.
You can use the Items property of RadGridView, where all items are in the order they appear in the grid. Getting the first item is as easy as "var firstItem = this.myGrid.Items[0]".
Hope this helps.
Best wishes,
Milan
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

Michał Polak
Top achievements
Rank 1
answered on 18 Feb 2010, 01:33 PM
OMG so simple, I must have been too tired yesterday.
Thank you for help :)
Best regards,
Michał
Michał
0

Levi
Top achievements
Rank 1
answered on 16 Sep 2011, 05:57 PM
It might be asking too much, but would it be possible for the Client-Side selected event to trigger (on page load) when a row is selected in the code behind??
0
Hello Levi,
SelectionChanged event will be fired.
What is the behavior that you want to achieve ?
Greetings,
Maya
the Telerik team
Would you clarify a bit what are your exact requirements ?
Generally, if you set the SelectedItem in code-behind:
this.clubsGrid.SelectedItem = this.clubsGrid.Items[0];
SelectionChanged event will be fired.
What is the behavior that you want to achieve ?
Greetings,
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0

Bryce
Top achievements
Rank 1
answered on 14 Dec 2011, 11:56 PM
Hi Maya,
Since I am binding my SelectedItem to something in my ViewModel, I get an exception when I do it the way you demonstrated. I have a sortdescriptor on my grid and in my ViewModel when I do SelectItem.FirstOrDefault(), I get the first item selected before the sortdescriptor sorts the grid. Is there a way around this?
Thanks,
Bryce
Since I am binding my SelectedItem to something in my ViewModel, I get an exception when I do it the way you demonstrated. I have a sortdescriptor on my grid and in my ViewModel when I do SelectItem.FirstOrDefault(), I get the first item selected before the sortdescriptor sorts the grid. Is there a way around this?
Thanks,
Bryce
0

Tyree
Top achievements
Rank 2
answered on 15 Dec 2011, 02:24 PM
For managing in a VM I find the easiest approach is you use a CollectionViewSource. Then you can manage selection, sorting, etc right from the VM and no monkeying with UI events and bindings.
To try it take your current collection and make it an ObservableCollection (if its not already). Create a public CollectionViewSource and sets its .Source to your ObservableCollection. Now bind your grids .ItemSource to the CollectionViewSource.View. Now in your VM you can do CollectionViewSource.View.CurrentItem to see whats selected, or if you set it you can make it select something else.
To try it take your current collection and make it an ObservableCollection (if its not already). Create a public CollectionViewSource and sets its .Source to your ObservableCollection. Now bind your grids .ItemSource to the CollectionViewSource.View. Now in your VM you can do CollectionViewSource.View.CurrentItem to see whats selected, or if you set it you can make it select something else.
0

Jose
Top achievements
Rank 1
answered on 12 Mar 2012, 03:15 PM
Hi,
I had the same problem.
You can try this:
Works with me.
Regards,
Jose
I had the same problem.
You can try this:
this
.clubsGrid.BeginInvoke( () =>
this
.clubsGrid.SelectedItem =
this
.clubsGrid.Items[0]);
Works with me.
Regards,
Jose
0

Walter
Top achievements
Rank 1
answered on 06 Dec 2012, 04:10 PM
grid.Records[n] deprecated in 2009 see
http://www.telerik.com/community/forums/silverlight/gridview/selectedrecord-deprecated-in-q2-2009.aspx
http://www.telerik.com/community/forums/silverlight/gridview/selectedrecord-deprecated-in-q2-2009.aspx