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

Shortcut key to sort RadGridViewColumn

2 Answers 179 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 15 Feb 2011, 04:06 PM
Hi,

I have a RadGridView and need to provide a keyboard short cut to allow the user to change the sort order using the keyboard.

How would you suggest, for example, the best method to set a keyboard shortcut of alt+N to change the sort for the Name column, i.e. mimic clicking on the column header.

Here is a small sample:

<telerik:RadGridView x:Name="mygridView" 
                     ItemsSource="{Binding MyItemsView}"
                     SelectedItem="{Binding MySelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                     IsSynchronizedWithCurrentItem="True"
                     SelectionMode="Single"
                     SelectionUnit="FullRow"
                     AutoGenerateColumns="False" 
                     IsReadOnly="True"
                     IsFilteringAllowed="False"
                     ShowGroupFooters="False"
                     ShowGroupPanel="False"
                     EnableRowVirtualization="True">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="Number" DataMemberBinding="{Binding Number}" IsSortable="True" Width="Auto" IsGroupable="False" />
        <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" IsSortable="True" Width="*"  IsGroupable="False" />
    </telerik:RadGridView.Columns>
    <telerik:RadGridView.SortDescriptors>
        <telerik:SortDescriptor Member="Name" SortDirection="Ascending" />
    </telerik:RadGridView.SortDescriptors>
</telerik:RadGridView>

 

 

 

Thanks,

Andy

2 Answers, 1 is accepted

Sort by
0
Andy
Top achievements
Rank 1
answered on 17 Feb 2011, 03:33 PM
Anyone any ideas?

Is it possible to add a keyboard gesture to the header click as it is out of the box or do I need to replace the content of the header and perform sorting programmatically?

Thanks in advance,

Andy
0
Ivan Ivanov
Telerik team
answered on 18 Feb 2011, 03:56 PM
Hi Andy,

Since the Alt key is involved in many system key combinations, it is strongly advisable to use another modifier key instead, i.e. Ctrl. I am sending you an implementation of column sorting, utilizing the Ctrl + N combination.

All the best,
Ivan Ivanov
the Telerik team
Tags
GridView
Asked by
Andy
Top achievements
Rank 1
Answers by
Andy
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Share this question
or