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

2 posts, 1 answers
  1. Ajay
    Ajay avatar
    66 posts
    Member since:
    May 2009

    Posted 09 Jun 2009 Link to this post

    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.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 Jun 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top