I have the following tag in my RadGrid:
When I click on the column to sort descending or ascending the column is highlighted in LightYellow as I expected. What do you have to do to clear the highlighted column?
Here is my SortCommand
Here is my NeedDataSource where I use ViewState to hold the data since I have a search form above the grid and need it to persist the gird. Without it the Grid becomes empty.
| <SortingSettings SortedBackColor="LightYellow" /> |
When I click on the column to sort descending or ascending the column is highlighted in LightYellow as I expected. What do you have to do to clear the highlighted column?
Here is my SortCommand
| protected void RadGrid1_SortCommand(object source, Telerik.Web.UI.GridSortCommandEventArgs e) |
| { |
| if (!e.Item.OwnerTableView.SortExpressions.ContainsExpression(e.SortExpression)) |
| { |
| // The intial page load will not have a NewSortOrder, so Ascending is set to default |
| GridSortExpression sortExpr = new GridSortExpression(); |
| sortExpr.FieldName = e.SortExpression; |
| sortExpr.SortOrder = GridSortOrder.Ascending; |
| e.Item.OwnerTableView.SortExpressions.AddSortExpression(sortExpr); |
| } |
| else |
| { |
| // After the initial page load we will have access to NewSortOrder |
| e.Canceled = true; |
| GridSortExpression sortExpr = new GridSortExpression(); |
| sortExpr.FieldName = e.SortExpression; |
| // If NewSortOrder is still empty set it to Ascending otherwise start using NewSortOrder |
| if (String.IsNullOrEmpty(Convert.ToString(e.NewSortOrder))) |
| { |
| sortExpr.SortOrder = GridSortOrder.Ascending; |
| } |
| else |
| { |
| sortExpr.SortOrder = e.NewSortOrder; |
| } |
| e.Item.OwnerTableView.SortExpressions.AddSortExpression(sortExpr); |
| RadGrid1.Rebind(); |
| } |
| } |
Here is my NeedDataSource where I use ViewState to hold the data since I have a search form above the grid and need it to persist the gird. Without it the Grid becomes empty.
| protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
| { |
| string gridSortString = this.RadGrid1.MasterTableView.SortExpressions.GetSortString(); |
| string text = "Grid sort expression: " + gridSortString; |
| DataSourceSelectArguments args = new DataSourceSelectArguments(gridSortString); |
| RadGrid1.DataSource = ViewState["DataTable1"]; |
| } |
