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

Disable auto first row selection in Grid

3 Answers 484 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anton Swanevelder
Top achievements
Rank 2
Anton Swanevelder asked on 08 Jul 2010, 05:43 PM
Hi,

Is there a way to disable the auto selection of the first row of the grid.

I want nothing to be selected when the user see the grid the first time.

Thanks in advance

3 Answers, 1 is accepted

Sort by
0
Accepted
Yavor Georgiev
Telerik team
answered on 08 Jul 2010, 05:47 PM
Hi Anton,

 You need to set the IsSynchronizedWithCurrenItem property on the RadGridView to False.

Best wishes,
Yavor Georgiev
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
Daniel Billingsley
Top achievements
Rank 1
answered on 12 Jul 2010, 02:56 PM
Thanks for this reply.  It solves my immediate problem.

However, what are the consequences of this for the following scenario?

If I have a button on each row, and I need to be able to detect the row/item associated with the particular button clicked, I have code like this in the button's click event:

GridViewRow row = (sender as UIElement).ParentOfType<GridViewRow>();
row.IsSelected;
// Is one of these better?
// myGridView.SelectedItem = row.Item;
// myGridView.CurrentItem = row.Item;

I'm currently using the first (IsSelected) option, per sample code provided to solve the scenario described, but I'm thinking that won't work any more with this synchronization turned off.

I ultimately just need to get the selected or current item (the item associated with the button/row) bound to a property in my ViewModel.  Would either of the last two lines work if I just bind their respective GridView property (SelectedItem vs. CurrentItem)?
0
Yavor Georgiev
Telerik team
answered on 12 Jul 2010, 03:04 PM
Hello Daniel Billingsley,

 Here's a bit more info on IsSynchronizedWithCurrentItem.

All the best,
Yavor Georgiev
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
Tags
GridView
Asked by
Anton Swanevelder
Top achievements
Rank 2
Answers by
Yavor Georgiev
Telerik team
Daniel Billingsley
Top achievements
Rank 1
Share this question
or