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

CustomBinding SortExpression - SortingName different to Model property name

2 Answers 16 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Fandi
Top achievements
Rank 1
Fandi asked on 10 Aug 2011, 02:50 AM
Hi,

I am using AJAX Custom Binding on Razor. The GridModel data contains collection of AccountModel.

One of property in AccountModel is called "GroupName", so when I am sorting by this column the GridCommand sorting descriptor member will contain "GroupName".

Is there a way to have sorting name to be different than the property name? Say I want it so the sorting name to be "AccountName" rather than "GroupName".

In my view there should be attribute in the Model which we can utilise to specify the sorting name, ie "Sorting attribute".

This is very simple example, but is important for me - and yes I could do If statement when ajax call my search function on controller and check the property name before changing it to sorting name manually - but that is so not clean, and there has to be better option.

Public Class AccountModel
 
    <Sorting(Name:="AccountName")> _
    <Display(Name:="Group Name")> _
    Public Property GroupName As String
 
End Class


Thanks
Fandi

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 Aug 2011, 06:14 AM
Hi Fandi,

 This is not supported. The grid will always sort using the bound field.

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

0
Luis
Top achievements
Rank 1
answered on 07 Jan 2012, 03:19 PM
Finally I got it!

With the help of the guys on this thread I'm proud to say that I came to a satisfactory result, pluggable in any type of MVC application without much difficulty and almost none in the settings.

I published the project on Bitbucket and Nuget, please take a look and send me some feedbacks.

https://bitbucket.org/Lunadie/telerikmvcgridcustombindinghelper/wiki/Home 

https://nuget.org/packages/TelerikMvcGridCustomBindingHelper  
Tags
Grid
Asked by
Fandi
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Luis
Top achievements
Rank 1
Share this question
or