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

SortAscImageUrl or SortDescImgUrl in GridTemplateColumn?

4 Answers 122 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 06 Feb 2013, 11:07 PM

Hi, I can't seem to get my sort arrow icons to appear for a GridTemplateColumn. There isn't even an "X" appearing as if it didn't find the file. Is there something special I need to do?

<telerik:RadGrid  ID="grdSearchResult" EnableEmbeddedSkins="false" ImagesPath="~/Images" runat="server" AllowSorting="true" AutoGenerateColumns="false" OnSortCommand="grdSearchResult_SortCommand" OnItemDataBound="grdSearchResult_OnItemDataBound">

<telerik:GridTemplateColumn ShowSortIcon="true" SortAscImageUrl="~/Images/down.png" SortDescImageUrl="~/Images/up.png">

....

Is there another setting or something I need to do in the OnSortCommand event?  Thanks, Dave

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Feb 2013, 04:35 AM
Hi,

Try setting SortExpression for the template column as shown below.
aspx:
<telerik:GridTemplateColumn  SortAscImageUrl="Images/img.png" SortExpression="FieldName"></telerik:GridTemplateColumn>

Thanks,
Shinu
0
David
Top achievements
Rank 1
answered on 07 Feb 2013, 04:46 AM
Thanks!  That seems to solve the issue of it appearing.

However, I'm trying to do something similar in the HeaderTemplate of this post http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx by adding a table to have a header and sub-header.  As it stands, the icon appears below the html table in the HeaderTemplate.  I'd like to have next to the column name.

Can you control where the Sort icon appears?  Otherwise I suppose I'll have to hide it again and somehow swap out an image using the binding events.  Thanks again for any thoughts. 

Dave.
0
Vasil
Telerik team
answered on 11 Feb 2013, 12:37 PM
Hello David,

See this online demo about the new from the last release functionality:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/multicolumnheaders/defaultcs.aspx

Regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Shinu
Top achievements
Rank 2
answered on 11 Feb 2013, 12:37 PM
Hi,

I suppose you want to add a custom image for the templatecolumn beside the HeaderText. Here is the sample code.
aspx:
<telerik:GridTemplateColumn DataField="ShippedDate">
                       <HeaderTemplate>
                           <table>
                               <tr>
                                   <td>
                                       Header text
                                   </td>
                                   <td>
                                       <asp:ImageButton ID="img" runat="server" CommandName="Sort" ImageUrl="~/Images/img.gif" />
                                   </td>
                               </tr>
                           </table>
                       </HeaderTemplate>
</telerik:GridTemplateColumn>

Thanks,
Shinu
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
David
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or