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

SortAscImageUrl & SortDescImageUrl not working; ShowSortIcon disables HeaderImageUrl

7 Answers 295 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Greg Chung
Top achievements
Rank 1
Greg Chung asked on 11 Jun 2008, 11:21 PM
I've run into two problems after switching my 4.6 grid to use the new 2008.1.415 grid, both relating to the sort direction arrow image in the grid header.

First, SortAscImageUrl and SortDescImageUrl  no longer seem to be doing anything at all.  No matter what I put in there, I get the standard little v and ^ arrow images.  I'm using a customized version of the WebBlue skin.  Every other part of the skin appears to be working.  I might be doing something wrong with the paths, but I don't think so, since this had been working in 4.6.

Second, in my GridTemplateColumn, my column heading is an icon, instead of text.  However, if I try to set ShowSortIcon="false" (which says it should turn off the sort arrow icon), it actually turns off my column heading icon!  Ack!

Here's an excerpt of my ASPX.  I've cut out some of the regular columns which are working properly:

                <telerik:RadGrid ID="InstanceListGrid" runat="server" AutoGenerateColumns="False" AllowSorting="True" Skin="CDSWebBlue"  
                    CssClass="TableHandCursor" GridLines="None" OnSortCommand="InstanceListGrid_SortCommand" Width="765px" 
                    OnItemDataBound="InstanceListGrid_ItemDataBound" EnableEmbeddedSkins="false"
                    <MasterTableView DataKeyNames="instance_id"
                        <ExpandCollapseColumn Visible="False"/> 
                        <RowIndicatorColumn Visible="False"/> 
                        <Columns> 
                            <telerik:GridBoundColumn DataField="port_desc" HeaderText="Description" UniqueName="port_desc" > 
                                    <HeaderStyle Width="200px" /> 
                            </telerik:GridBoundColumn> 
                            <telerik:GridTemplateColumn SortExpression="NeedToSave" HeaderImageUrl="~/Resources/Images/icon_02a_save_16x16.gif" HeaderStyle-Wrap="false" ShowSortIcon="false" SortAscImageUrl="~/Resources/Images/icon_99_placeholder.gif" SortDescImageUrl="~/Resources/Images/icon_99_placeholder.gif"
                                <HeaderStyle Width="26px" /> 
                                <ItemTemplate> 
                                    <asp:Image ID="Image1" ImageUrl="~/Resources/Images/icon_02a_save_16x16.gif" runat="server"  /> 
                                     
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
 

Basically, the GridTemplateColumn shows a little diskette icon as its header.  Then, for rows representing data which needs to be saved, it shows the diskette icon again, or just a blank for other rows.  If I set ShowSortIcon="false" (as in the snipped above), I just see a blank gap in the column header -- no diskette icon there.  And, without ShowSortIcon="false", the SortAsc and SortDesc images don't use the images I want.  Note that the path to my SortAsc and SortDesc images is the same as the path to the HeaderImageUrl (which does display), so I know my paths are good.

The SortAsc and SortDesc image properties don't seem to have any effect on any of the grid columns, but it's only for this template column where I had a need to override the defaults.

Thanks for your advice.


7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Jun 2008, 08:15 AM
Hi,

Try setting the ImageUrl for the sort image in the code behind as shown below.

CS:
protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)  
        {  
            if (col.UniqueName == "ColumnUniqueName")  
            {  
                  col.SortAscImageUrl = "~/Resources/Images/icon_99_placeholder.gif";  
                  col.SortDescImageUrl"~/Resources/Images/icon_99_placeholder.gif";          
            }  
        }  
         
    } 


Princy.
0
Greg Chung
Top achievements
Rank 1
answered on 12 Jun 2008, 03:16 PM
Hi Princy-

Thanks for the suggestion.  I tried it, but to no avail.  Inside the PreRender function, the col.SortAscImageUrl  field already had the correct value, from the column attribs in the ASPX.


0
Princy
Top achievements
Rank 2
answered on 13 Jun 2008, 06:24 AM
Hi,

Try rebinding the Grid in the PreRender event and see whether it is working.

protected void RadGrid1_PreRender(object sender, EventArgs e)     
    {     
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)     
        {     
            if (col.UniqueName == "ColumnUniqueName")     
            {     
                  col.SortAscImageUrl = "~/Resources/Images/icon_99_placeholder.gif";     
                  col.SortDescImageUrl"~/Resources/Images/icon_99_placeholder.gif";             
            }     
        }     
            
        RadGrid1.Rebind();  
    }    


Princy.
0
Greg Chung
Top achievements
Rank 1
answered on 13 Jun 2008, 01:57 PM
Still no good. :(

The two problems remain: the SortAsc/DescImageUrl values are populated correctly by the time I enter the PreRender... and why does ShowSortIcon = false completely turn off the header?

Telerik -- any thoughts here?


0
Accepted
Iana Tsolova
Telerik team
answered on 16 Jun 2008, 02:17 PM
Hi Greg Chung,

Please try using the ImagesPath property of your RadGrid to specify the location for all images, which are not referenced by the skin (paging, filtering, etc) for solving your first problem. For instance:

<telerik:RadGrid ID="RadGrid1" runat="server" ImagesPath="Resources/Images/">  
</telerik:RadGrid> 

Regarding your second problem:
I will address the issue to our developers and for further investigations and hope you will find it fix in our next version release.

Let us know if this helps.

Sincerely yours,
Iana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Greg Chung
Top achievements
Rank 1
answered on 16 Jun 2008, 02:43 PM
Thanks for that.  I set ImagesPath to the folder the default images which came with the skin (~/RadControls/Skins/CDSWebBlue/Grid in my case).  After doing this, my customized sort direction icons began working, even though they're in a different folder (~/Resources/Images).

It seems like a bug that the sort asc/dec images URL settings would require ImagesPath to be set, while the header URL setting was working fine without it (and, the fact that it worked fine in 4.6).  Still, I can use ImagesPath as a workaround.

Thanks very much


0
Iana Tsolova
Telerik team
answered on 17 Jun 2008, 12:53 PM
Hi Greg Chung,

Please find attached a sample project where I have set the images for the asc and desc sorting successfully.

Additionally, I suggest that you review the this help topic about RadGrid migration and the section there Skin migration and this topic about grid Skins. 

Let us know if any issues arise.

Greetings,
Iana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Greg Chung
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Greg Chung
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or