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

[Solved] RadGridView Sorting Order

4 Answers 304 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Leon
Top achievements
Rank 1
Leon asked on 30 Jul 2010, 04:24 PM
Hey All,

I have a RadGridView with several columns in it...some strings, some DateTime, Some Integer.

I need a way to sort these columns...I am overriding the Sorting event and doing my sorting as such:

IOrderedEnumerable<TableViewRow> sortedValue;

                        sortedValue = from item in dgStudyList.Items.OfType<TableViewRow>()
                                      orderby ConvertToDateTime(item.Data[columnName] as string) ascending
                                      select item;

grid.ItemsSource = sortedValue.ToList();

this works fine and is okay.

The problem I run into is I want to do an initial sort on the table on initialization.  When I use the SortDescriptors property to sort, it sorts by string...not by int or dateTime (which works for the columns which have strings in them).  However, if I initially do the sort using the above method (which is needed to sort by date, or int), the little triangle in the row headers (which show sort direction) do not get set.  This seems like a pretty strait forward problem. 

Is there any way to set those or do a sort which will set those arrows accordingly.

Thanks

Leon

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 02 Aug 2010, 04:21 PM
Hello Leon,

 Why not create a model with additional DateTime property on the top of your original data and let the grid to sort instead?

Kind regards,
Vlad
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
Leon
Top achievements
Rank 1
answered on 02 Aug 2010, 07:05 PM
Hey,

Thanks for your reply.

Sorry for being so green, but I am kind of new to this.  Can you point me to an example I can work from?

Thanks

Leon
0
Vlad
Telerik team
answered on 03 Aug 2010, 06:35 AM
Hi,

 The idea is to create new class and inherit from your original class. You can add new DateTime property to this new class.

Greetings,
Vlad
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
preeti
Top achievements
Rank 1
answered on 11 Nov 2010, 11:43 AM
Hi All,

I have applied sort settings to my Silverlight RadGridView collumn. my code is something like this

grid.SortDescriptors.Clear();

 

foreach (SortSetting setting in Settings.SortSettings)

 

{

Telerik.Windows.Data.

 

SortDescriptor d = new Telerik.Windows.Data.SortDescriptor();

 

 

d =

 

new Telerik.Windows.Data.SortDescriptor();

 

d.Member = setting.PropertyName;

d.SortDirection = setting.SortDirection;

grid.SortDescriptors.Add(d);

}

I have some editable collumns on my grid so after adding these descripters when i try to edit fields on grid then after editing when i move to other row the grid gets reloaded.

i tried to chk wether it is sorting or loading again but these events is not fired.
plz help me this is very urgent.

Tags
GridView
Asked by
Leon
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Leon
Top achievements
Rank 1
preeti
Top achievements
Rank 1
Share this question
or