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

Setting default sorting back color to GridTemplateColumn

5 Answers 253 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sreekanth
Top achievements
Rank 1
Sreekanth asked on 11 Jun 2012, 10:40 PM
How can we set the default skin sort style to GridTemplateColumn? It is working for GridBoundColumn but not for GridTemplateColumn. I have tried different colors from the Sortedbackcolor but I couldn't find the default color. Can somebody please help me with this?

<telerik:GridTemplateColumn HeaderText="Status" SortedBackColor="???" SortExpression="Active">
</telerik:GridTemplateColumn>

-Sree  

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Jun 2012, 05:06 AM
Hello Sree,

Here is the sample code that I tried based on your scenario.
aspx:
<telerik:GridTemplateColumn SortedBackColor="#F2F2F2"  SortExpression="OrderID" UniqueName="TempCol" HeaderText="test">
 <ItemTemplate>
   <asp:Label ID="Label8" runat="server" Text='<%# Eval("OrderID") %>'></asp:Label>
 </ItemTemplate>
</
telerik:GridTemplateColumn>

Thanks,
Princy.
0
Kai
Top achievements
Rank 2
answered on 12 Sep 2012, 01:51 PM
Hi Princy,
thanks for the info! I have a similar question: I want the design of my GridTemplateColumns to be the same like in GridBoundColumns. In GridBound column the backcolor changes between F2F2F2 and E6E6E6 on alternate rows, additionally there is a small triangle to indicate current sort order. Is it possible to build the same design for a GridTemplateColumn?
Thanks
Kai
0
Princy
Top achievements
Rank 2
answered on 13 Sep 2012, 05:29 AM
Hi Kai,

 I couldn't replicate the issue. The GridBoundColumn and GridTemplateColumn design are same after sort, ie same color and the sort icon. I guess you have set the SortedBackColor for the TemplateColumn, then it won't show different backcolor for alternate rows. the sort icon will display unless the property 'ShowSortIcon' is set to 'false'.

ASPX:
<telerik:GridTemplateColumn  SortExpression="OrderID" ShowSortIcon="true" UniqueName="TempCol" HeaderText="test">
        <ItemTemplate>
            <asp:Label ID="Label8" runat="server" Text='<%# Eval("OrderID") %>'></asp:Label>
        </ItemTemplate>
</telerik:GridTemplateColumn>


Please provide the code if it doesn't help.

Thanks,
Princy.
0
Kai
Top achievements
Rank 2
answered on 13 Sep 2012, 10:41 AM
Hi Princy,
yes, you're right, thanks! Now the coloring is correct, but the sort icon is not displayed. Please see the code below. I'm using a selfmade Headertable. When I set "InitializeTemplatesFirst" to "true", sort icon is displayed next to the Header Text but then it's displayed twice (one from the Header, one from the Link Button). It would be perfect to have one column header and then the search icon and the sort icon in the same line. Currently it would be on 2 lines. Anyway it's not too important, so i could understand if that does not work and so I'll miss the sort icon, no problems.

<telerik:GridTemplateColumn DataField="BusinessFocus" GroupByExpression="BusinessFocus Group By BusinessFocus"
                        UniqueName="BusinessFocus" InitializeTemplatesFirst="false"
                        HeaderText="Business Focus" ShowSortIcon="true" SortExpression="BusinessFocus">
                        <HeaderTemplate>
                            <table>
                                <tr>
                                    <td>
                                        <asp:LinkButton ID="lnkSortBusinessFocus" runat="server" CommandArgument="BusinessFocus"
                                            CommandName="Sort" Text="Business Focus"></asp:LinkButton>
                                    </td>
                                    <td>
                                        <img src="Images/Search.png" style="margin-top: 5px; margin-left: 5px; cursor: pointer"
                                            onclick='ShowColumnHeaderMenu(event,"BusinessFocus")' alt="Show context menu" />
                                    </td>
                                </tr>
                            </table>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <%#Eval("BusinessFocus") %>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
0
Galin
Telerik team
answered on 18 Sep 2012, 08:19 AM
Hello Kai,

You can add a sort button to the template ant to set the CommandName property to "Sort" and the sort expression as the CommandArgument for the button. The RadGrid will handle the sorting automatically when the user clicks the button, e.g.
<HeaderTemplate>
    <table>
        <tr>
            <td>
                <asp:LinkButton ID="lnkSortBusinessFocus" runat="server" CommandArgument="BusinessFocus"
                    CommandName="Sort" Text="Business Focus"></asp:LinkButton>
            </td>
            <td>
                <img src="images/lineBottom.gif" style="margin-top: 5px; margin-left: 5px; cursor: pointer"
                    onclick='ShowColumnHeaderMenu(event,"BusinessFocus")' alt="Show context menu" />
            </td>
            <td>
                <asp:Button ID="Button1" runat="server" Text="Sort" Title="Sort by BusinessFocus" CommandName='Sort' CommandArgument='BusinessFocus' />
            </td>
        </tr>
    </table>
</HeaderTemplate>

I hope this helps.

All the best,
Galin
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.
Tags
General Discussions
Asked by
Sreekanth
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kai
Top achievements
Rank 2
Galin
Telerik team
Share this question
or