I've searched like crazy and just can't seem to find an answer to this. I have a RadGridView, which has a sort order set with a SortDescriptor. This works perfectly. However, I don't want the user to be able to change the sort order. I don't see an obvious way to achieve this.
I tried the answer here: http://www.telerik.com/forums/radgridview-and-sort#HOkVZJ4q4UqUdzg5ZW-sgg in that I overrode the Header Cells. I don't have anything in OnMouseUp, just like the example, but sorting was still allowed to occur.
I then tried overriding the Sort event, which worked, with a caveat. Here's the code I have now:
private void ingredientsGridView_CreateCell(object sender, GridViewCreateCellEventArgs e)
{
if (e.CellType == typeof(GridHeaderCellElement))
{
e.CellType = typeof(MyHeaderCell);
}
}
public class MyHeaderCell : GridHeaderCellElement
{
public MyHeaderCell(GridViewColumn column, GridRowElement row)
: base(column, row)
{ }
protected override Type ThemeEffectiveType
{
get { return typeof(GridHeaderCellElement); }
}
//protected override void OnMouseUp(MouseEventArgs e)
//{
// //base.OnMouseUp(e);
// //MessageBox.Show("Nope");
//}
public override void Sort(RadSortOrder sortOrder)
{
//base.Sort(sortOrder);
}
}
As I stated, this works, but the caveat is that the user still sees options to sort in the context menu, etc. Is there a better way to achieve what I want, allowing sorting in code but keeping the user from sorting?
Thanks