Reputation: 3051
I'm using a DevExpress GridView in my application (My company still uses the old DevExpress v7.2). I have four columns, on which one of them is the "Priority" column. Status is an enumeration with three possible values: Critical, High and Low.
When the user wants to sort the GridView by this column, I want to sort by level of severity but also within the items with severity "Critical" (for example) I want the values to be sorted by date from the earliest to the latest.
If anyone can help that would be awesome.
Thanks! John.
Upvotes: 1
Views: 3417
Reputation: 86
I'm not sure how your implementing your sorting but you could always intercept looking for a sort on your "Priority" column, then append a secondary sort on the date column.
I've done this type of thing before, mine is overkill for what your looking to do but the basic code would be something like this:
public void GridView_ExampleSorting(object sender, GridViewSortEventArgs e)
{
GridView gv = (GridView)sender;
DataTable dataTable = gv.DataSource as DataTable;
if (dataTable != null)
{
string sortdirection = GetNextSortDirection(e.SortExpression);
DataView dataView = new DataView(dataTable);
dataView.Sort = e.SortExpression + " " + sortdirection;
if (e.SortExpression.ToString() == "priority")
dataView.Sort += " date DESC";
gv.DataSource = dataView;
gv.PageIndex = 0;
gv.DataBind();
}
}
Upvotes: 2
Reputation: 2210
In the newer versions of the grid control you could hold down the ctrl key and click on the 2'nd coulmn header to sort by that column as well as the 1'st one. But I'm not sure if it will also work on version 7 of the grid.
Update: its actually the shift key. please see here
Upvotes: 2