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

Sort TemplateColumn

3 Answers 178 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James Van Buren
Top achievements
Rank 2
James Van Buren asked on 12 Nov 2008, 08:59 PM

Is there a problem with sorting Template Column?
I bind the grid to Anonymus Type on codebehind 
Sorting any other column GridBoundColumn  or GridDateTimeColumn
works fine.
please advise......
below is my code.

 
 
<telerik:GridBoundColumn DataField="rs.ReqServiceID" SortExpression="rs.ReqServiceID" HeaderText="ServiceID"/>  
 
 
 
<telerik:GridDateTimeColumn DataField="rs.DateFollowup" SortExpression="rs.DateFollowup" HeaderText="Followup Date" Groupable="true" Aggregate="Min" DataType="System.DateTime" FilterListOptions="VaryByDataType" HeaderStyle-Width="140" DataFormatString="{0:g}"/>  
 
 
 
 
<telerik:GridTemplateColumn HeaderText="User" SortExpression="rs.UserName" DataField="rs.UserName" UniqueName="rs.UserName">  
 
<ItemTemplate> 
 
<asp:Image ImageUrl="~/images/service_edit.png" Visible='<%#IIF(Eval("rs.UserName")<>"", "true","false")%>' ID="imgUserName" runat="server" ImageAlign="AbsBottom"/>&nbsp;<%#Eval("rs.UserName")%> 
 
</ItemTemplate> 
 
</telerik:GridTemplateColumn> 
 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Nov 2008, 07:35 AM
Hi James,

To enable sorting for a  GridTemplateColumn, you need to set appropriate SortExpression values for those columns and the SortExpression value should match the data field you want to sort on (typically the field a control in the template is bound to). I tried implementing sorting for Template column on my end and it is working fine. Not sure what is wrong on your end. I would suggest you to submit a support ticket so that telerik can help you on this regard.

Shinu.
0
James Van Buren
Top achievements
Rank 2
answered on 13 Nov 2008, 05:14 PM
thanks for reply.
if you look at my code that's exactly what i'm doing
SortExpression="rs.UserName" 

is the same fieldname expression as what i bind to latter in itemtemplate <%#Eval("rs.UserName")%> 

I think there is a problem for RadGrid's ItemTemplate to sort on anonymus type object, but regular databound fileds bind and sort just fine
.
System.IndexOutOfRangeException: Cannot find column
0
Juan Angel
Top achievements
Rank 1
Veteran
answered on 20 Apr 2009, 11:36 PM
Tags
Grid
Asked by
James Van Buren
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
James Van Buren
Top achievements
Rank 2
Juan Angel
Top achievements
Rank 1
Veteran
Share this question
or