Note that there are some explanatory texts on larger screens.

plurals
  1. POTelerik RADGrid and sorting
    primarykey
    data
    text
    <p>I'm using the RADGridView for WPF to display some data. It is pulled dynamically from DB so I don't know column names or the type of data contained in each cell. I want to let the user sort the data on each column when it double-clicks on a column header.</p> <p>For some reason the grid doesn't sort. This is what I have so far.</p> <pre><code>private void SetEventHandlers() { if (_grid != null) { _grid.AddHandler(GridViewCellBase.CellDoubleClickEvent, new EventHandler&lt;RadRoutedEventArgs&gt;(OnCellDoubleClick), true); } } private void OnCellDoubleClick(object sender, RoutedEventArgs e) { GridViewCellBase cell = e.OriginalSource as GridViewCellBase; if (cell != null &amp;&amp; cell is GridViewHeaderCell) { SetSorting(cell); } } private void SetSorting(GridViewCellBase cell) { GridViewColumn column = cell.Column; SortingState nextState = GetNextSortingState(column.SortingState); _grid.SortDescriptors.Clear(); if (nextState == SortingState.None) { column.SortingState = SortingState.None; } else { _grid.SortDescriptors.Add(CreateColumnDescriptor(column, nextState)); column.SortingState = nextState; } } </code></pre> <p>EDIT:</p> <pre><code>private ColumnSortDescriptor CreateColumnDescriptor(GridViewColumn column, SortingState sortingState) { ColumnSortDescriptor descriptor = new ColumnSortDescriptor(); descriptor.Column = column; if (sortingState == SortingState.Ascending) { descriptor.SortDirection = ListSortDirection.Ascending; } else { descriptor.SortDirection = ListSortDirection.Descending; } return descriptor; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload