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

Bind sort index to a property

1 Answer 94 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jan Paolo
Top achievements
Rank 1
Jan Paolo asked on 06 May 2019, 08:47 PM

Hello, Is there a way to bind the sort index to a property?
For example, we have the following class

public class Foo
{
    public string Name { get; set; }
    public int SortIndex { get; set; }
}

If the user clicks a column header and turns it to ascending order then the the SortIndex of the items should be updated with respect to how it was sorted in the UI.

Thanks!

Jan

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 09 May 2019, 09:52 AM
Hi Jan Paolo,

The SortingIndex property of the GridViewDataColumn can not be bound. What you could try to get the SortingIndex is to subscribe to the Sorted event of the RadGridView. In the event handler, you can get the current sorted Column from the event arguments and get its SortingIndex property.
private void MyGridView_Sorted(object sender, GridViewSortedEventArgs e)
{
    var header = e.Column.Header;
    var column = e.Column.SortingIndex;
}

Then you could update your property from your model. Hope this approach will work for you.

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Jan Paolo
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or