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

Using button to select next/previous row?

2 Answers 99 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 15 Mar 2012, 12:13 AM
I have a page with a telerik RadGridView and a couple of buttons.  I'd like clicking the buttons to select the previous/next rows from the grid.  So I'm trying out RadGridViewCommands from the button's Click events:

private void prevButton_Click(object sender, RoutedEventArgs e)
{
    var cmd = RadGridViewCommands.MovePrevious as RoutedUICommand;
    cmd.Execute(null, myGrid);
}

The various move commands change the focus, but they do not change the selected row.

I've tried MoveUp, followed by SelectCurrentItem, but that doesn't seem to change the selection at all.

Ideas?

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 15 Mar 2012, 12:02 PM
Hello,

 To select the item, please execute this command as well:

RadGridViewCommands.SelectCurrentUnit

Does it help?

Kind regards,
Didie
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Jeff
Top achievements
Rank 1
answered on 15 Mar 2012, 04:04 PM
From the description, I'd thought that SelectCurrentUnit() did something very different.

But doing a MoveDown() followed by a SelectCurrentUnit() gave me the behavior I wanted.

Since I asked the question, I've discovered that doing a MoveCurrentToNext() on the QueryableCollectionView that the grid is bound to also works, and seems to provide a cleaner separation of concerns.
Tags
GridView
Asked by
Jeff
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Jeff
Top achievements
Rank 1
Share this question
or