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

Column Sort Icon not changing

4 Answers 163 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Luke Kasper
Top achievements
Rank 1
Luke Kasper asked on 28 Oct 2010, 02:10 PM
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.

4 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 28 Oct 2010, 03:33 PM
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
0
Luke Kasper
Top achievements
Rank 1
answered on 28 Oct 2010, 07:18 PM
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.
0
Luke Kasper
Top achievements
Rank 1
answered on 28 Oct 2010, 07:23 PM
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.
0
Dimo
Telerik team
answered on 29 Oct 2010, 07:16 AM
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
Tags
Grid
Asked by
Luke Kasper
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Luke Kasper
Top achievements
Rank 1
Share this question
or