Column Sort Icon not changing

5 posts, 0 answers
  1. Luke Kasper
    Luke Kasper avatar
    18 posts
    Member since:
    Mar 2010

    Posted 28 Oct 2010 Link to this post

    All,

    I'm trying to change my SortAsc and SortDesc icons on my grid, and I'm not getting any noticeable change.  I create the grid programmatically, so I use the method listed in the documentation.  I wired up my ColumnCreated event to the following function:

    protected void rgrid_ColumnCreated(object source, GridColumnCreatedEventArgs e)
    {
        e.Column.SortAscImageUrl = "Grid/Skins/SortAsc.gif";
        e.Column.SortDescImageUrl = "Grid/Skins/SortDesc.gif";
    }

    The result:
    Nothing.  The default arrows (gray/black up and down arrows) are used no matter what I put in there. My "Grid" directory sits on the same level as the .cs file this function is in.  I've tried adding / and ../ in front of the url names, all to no avail.

    Any help would be GREATLY appreciated.
  2. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 28 Oct 2010 Link to this post

    Hi Luke,

    The following simple demo works as expected on my side. Please compare with your implementation.

    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
     
    <script runat="server">
     
    protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        DataTable dt = new DataTable();
        DataRow dr;
        int colsNum = 4;
        int rowsNum = 4;
        string colName = "Column";
     
        for (int j = 1; j <= colsNum; j++)
        {
            dt.Columns.Add(String.Format("{0}{1}", colName, j));
        }
     
        for (int i = 1; i <= rowsNum; i++)
        {
            dr = dt.NewRow();
     
            for (int k = 1; k <= colsNum; k++)
            {
                dr[String.Format("{0}{1}", colName, k)] = String.Format("{0}{1} Row{2}", colName, k, i);
            }
            dt.Rows.Add(dr);
        }
     
        (sender as RadGrid).DataSource = dt;
    }
     
    protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
    {
        e.Column.SortAscImageUrl = "~/grid_images/Delete.gif";
        e.Column.SortDescImageUrl = "~/grid_images/AddRecord.gif";
    }
    </script>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     
    <head runat="server">
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <title>RadControls</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
     
    <telerik:RadGrid
        ID="RadGrid1"
        runat="server"
        Skin="Office2007"
        AllowSorting="true"
        Width="800px"
        OnNeedDataSource="RadGrid_NeedDataSource"
        OnColumnCreated="RadGrid1_ColumnCreated">
    </telerik:RadGrid>
     
    </form>
    </body>
    </html>


    Best wishes,
    Dimo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Luke Kasper
    Luke Kasper avatar
    18 posts
    Member since:
    Mar 2010

    Posted 28 Oct 2010 Link to this post

    I notice you have a Skin defined.  Do I need to define a skin in order to modify the Sort icons?  Besides that, the only real difference I see is that my radgrid is created programmatically and inserted into an empty div on the control.
  5. Luke Kasper
    Luke Kasper avatar
    18 posts
    Member since:
    Mar 2010

    Posted 28 Oct 2010 Link to this post

    I wasn't able to get the ColumnCreated method to work, however I was able to get it to work another way.  I set rgrid.ImagesPath to my images directory, and it looks like it's working now.
  6. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 29 Oct 2010 Link to this post

    Hi Luke,

    >> Do I need to define a skin in order to modify the Sort icons?

    No, it is not necessary to use a skin in order to modify the sort icons.

    It is possible that the programmatic creation is not correct. Anyway, I am glad that you have resolved this.

    http://www.telerik.com/help/aspnet-ajax/grdprogrammaticcreation.html

    Kind regards,
    Dimo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017