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

Rad Grid Column Heads should show UP /DOWN ARROW to show SORT ORDER

1 Answer 236 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ajay
Top achievements
Rank 2
Ajay asked on 09 Jun 2009, 03:49 PM
Hi folks !

Iam using the  RAD GRID from ASP.NET AJAX UI Controls.

I want to have an up/down arrow to be marked on to my grid header so that I will be availabe to sort the column of the grid.

Iam using GRAY skin for my RAD GRID.

Please help me sort out my problem.

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 10 Jun 2009, 06:36 AM
Hello Ajay,

The Gray skin should automatically display sort images when sorting. If you want to display an image when the column is not sorted then you can add an image to the header of columns when the sortorder is none and remove it for the ascending/descending sort orders .

To add an image to the header when the sortorder is none you can try out the following code:
c#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridHeaderItem)  
        {  
            GridHeaderItem header = (GridHeaderItem)e.Item;  
            Image img = new Image();  
            img.ID = "Image1";  
            img.ImageUrl = "~/Images/SortArrow.GIF";             
             
                header["ColumnUniqueName"].Controls.AddAt(1, img);  
                if (RadGrid1.MasterTableView.SortExpressions.Count != 0 && RadGrid1.MasterTableView.SortExpressions[0].FieldName == "ColumnUniqueName")  
                {  
                    if (RadGrid1.MasterTableView.SortExpressions[0].SortOrder != GridSortOrder.None)  
                    {  
                        header["ColumnUniqueName"].Controls.Remove(img);  
                    }  
                }                   
            }  
      } 

Thanks
Princy.
Tags
Grid
Asked by
Ajay
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Share this question
or