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

[Solved] GridTemplateColumn sortable with a LinkButton?

3 Answers 199 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Laz
Top achievements
Rank 1
Laz asked on 25 Jun 2009, 08:44 AM

Hi to all,

it is not possible for me to make a GridTemplateColumn sortable with a LinkButton - control inside?

For my RadGrid i have set the attributes AllowMultiColumnSorting="true" and have define a <SortExpressions> Tag for a default sortexpression.

I don´t know if this information is important for problem solving?


The GridTemplateColumn with the UniqueName="WText" is not sortable in my example code

            <telerik:RadGrid ID="rdgWI" 
                             runat="server"   
                             AutoGenerateColumns="False" 
                             GridLines="None" 
                             onneeddatasource="rdgWI_NeedDataSource"   
                             PageSize="8" 
                             AllowSorting="True" 
                             Width="100%">  
                <HeaderContextMenu> 
                    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                </HeaderContextMenu> 
 
                <ClientSettings> 
                    <Scrolling AllowScroll="True" UseStaticHeaders="true" /> 
                    <ClientEvents OnGridCreated="GetGridObject"></ClientEvents> 
                </ClientSettings> 
 
                <MasterTableView ClientDataKeyNames="WRhText, WiRhTask, WId, WText" ShowHeadersWhenNoRecords="true" AllowMultiColumnSorting="true" ShowHeader="true" runat="server" Width="99%">  
                     
                    <RowIndicatorColumn> 
                        <HeaderStyle Width="20px"></HeaderStyle> 
                    </RowIndicatorColumn> 
                    <ExpandCollapseColumn> 
                        <HeaderStyle Width="20px"></HeaderStyle> 
                    </ExpandCollapseColumn> 
                   <SortExpressions> 
                        <telerik:GridSortExpression FieldName="WRhText" SortOrder="Ascending" /> 
                    </SortExpressions> 
                    <Columns> 
                        <telerik:GridBoundColumn DataField="WId" UniqueName="WId" Visible="false">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridTemplateColumn HeaderText="Category" SortExpression="WRhText"   
                            UniqueName="WCategory" DataField="WRhText" Visible="false">  
                            <ItemTemplate> 
                                <asp:Label ID="lblWCategory" runat="server" CssClass="DefaultText"   
                                    Text='<%# GetWorklistTypText(Eval("WRhTask")) %>' /> 
                            </ItemTemplate> 
                        </telerik:GridTemplateColumn> 
                        <telerik:GridTemplateColumn HeaderText="Description" SortExpression="WText" 
                            UniqueName="WText" > 
                            <ItemTemplate> 
                                <asp:LinkButton ID="lbWText" runat="server" 
                                    CommandArgument='<%# Eval("WId") %>'   
                                    CommandName="ShowDetails"   
                                    Text='<%# Eval("WText") %>' OnCommand="btnShowDetails">  
                                </asp:LinkButton> 
                        </ItemTemplate> 
                        </telerik:GridTemplateColumn> 
                    </Columns> 
                </MasterTableView> 
                <FilterMenu> 
                    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                </FilterMenu> 
            </telerik:RadGrid> 

Thank for your help

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 25 Jun 2009, 11:57 AM
Hi Laz,

To add a sort LinkButton to a TemplateColumn in the Grid you should set the CommandName property to "Sort" and the sort expression as the CommandArgument for the button. RadGrid can then handle the sorting automatically when the user clicks the button.

Sincerely yours,

Pavlina
the Telerik team

 


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Laz
Top achievements
Rank 1
answered on 25 Jun 2009, 12:17 PM
Hi,

i have followed your notice. But why the SortIcon isn´t show, and why isn´t a colum color shown?

I set ShowSortIcon="true" but no SortIcon is shown?

 <telerik:GridTemplateColumn HeaderText="Description" DataField="WText" SortExpression="WText" ShowSortIcon="true" 
                            UniqueName="WText">  
                            <HeaderTemplate> 
                                <asp:LinkButton ID="SortButton"   
                                                runat="server"   
                                                Text="Decision"   
                                                ToolTip="Click to sort"   
                                                CommandName='Sort'   
                                                CommandArgument='WText'>  
                                </asp:LinkButton> 
                            </HeaderTemplate> 
                            <ItemTemplate> 
                                <asp:LinkButton ID="lbWText" runat="server" 
                                    CommandArgument='<%# Eval("WId") %>'   
                                    CommandName="ShowDetails"   
                                    Text='<%# Eval("WText") %>' OnCommand="btnShowDetails">  
                                </asp:LinkButton> 
                            </ItemTemplate> 
</telerik:GridTemplateColumn> 
 

Thank you in advance
0
Pavlina
Telerik team
answered on 25 Jun 2009, 02:25 PM
Hello Laz,

I am sending you a simple runnable application that demonstrates the needed approach. Please give it a try and see if it works for you or if I am leaving something out.

Greetings,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Laz
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Laz
Top achievements
Rank 1
Share this question
or