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

Custom Sorting

1 Answer 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gemma
Top achievements
Rank 1
Gemma asked on 10 Feb 2012, 01:11 PM
Hi,

I'm trying to implement sorting on a custom field, could someone provide me with an example

Code as below, would want to implement sorting on

 

<telerik:RadGrid ID="rgContactsResult" runat="server" Width="99%" AllowPaging="True" AllowSorting="true"

 

GridLines="None" PageSize="10" AllowFilteringByColumn="True" AutoGenerateColumns="false">

<PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" Wrap="false"></PagerStyle>

<GroupingSettings CaseSensitive="false" />

 <ClientSettings EnablePostBackOnRowClick="true">

 <Selecting AllowRowSelect="true" />

 <KeyboardNavigationSettings AllowSubmitOnEnter="true" />

 </ClientSettings>

 <MasterTableView CommandItemDisplay="None">

 <Columns>

 <telerik:GridBoundColumn HeaderText="Our Ref" UniqueName="contactID" DataField="contactID" AllowFiltering="false" >

  <telerik:GridTemplateColumn HeaderText="ContactJob" UniqueName="ContactJob" AllowFiltering="false">
<ItemTemplate>

 <%# ContactJob(DataBinder.Eval(Container.DataItem, "ContactID"))%>

 </ItemTemplate>

 </telerik:GridTemplateColumn>

 </Columns>

 </MasterTableView>

</telerik:RadGrid>

Thanks

 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 13 Feb 2012, 05:17 AM
Hello,

When using custom sorting, the following things that you need to ensure:

1. RadGrid is bound to a data source using its NeedDataSource event, but not to a automatic DataSource Controls (SlqDAtaSource, AccessDataSource, etc).

2. The AllowCustomSorting property of the MasterTableView needs to be set to true.

3. You should not cancel your sort command if you need to preserve the sorting images.
Also take a look into this documentation and demo.

Thanks,
Princy.
Tags
Grid
Asked by
Gemma
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or