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

[Solved] Sort by text in a template column

1 Answer 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mattias
Top achievements
Rank 1
Mattias asked on 05 Jan 2010, 07:38 AM
Hi,
I have this code in my grid:
<telerik:GridTemplateColumn UniqueName="Unit" HeaderText="<%$ Resources:resources, Label_HomeDirectory %>"
     <ItemTemplate> 
           <asp:Label ID="labelUnit" runat="server" Text=""></asp:Label> 
     </ItemTemplate> 
</telerik:GridTemplateColumn> 

protected void radGridUsers_ItemDataBound(object sender, GridItemEventArgs e) 
     GridDataItem gridItem; 
     User user; 
 
     if (e.Item is GridDataItem) 
     { 
          gridItem = (GridDataItem)e.Item; 
          user = (User)gridItem.DataItem;  
          Label labelUnit = (Label)gridItem.FindControl("labelUnit"); 
          labelUnit.Text = UnitService.GetParentUnits(user.Unit.ID) + user.Unit.Name;  
     } 
 

The text in the label could look like: My first unit/ My second unit/ My third unit

Is it possible to sort the grid by this text in for example prerender event?

Regards,
Mattias

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 05 Jan 2010, 03:39 PM
Hi Mattias,

Please, refer to the following help article, which explains how to attain sorting with GridTemplateColumn.
Sorting for GridHyperLinkColumn/GridTemplateColumn

Examine it and let me know if you need additional assistance.

Best wishes,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Mattias
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or