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

Sorting a DateTime Column

2 Answers 36 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jonathon
Top achievements
Rank 1
Jonathon asked on 19 Nov 2011, 12:38 AM
Hi,

I've looked through the threads on these forums, and have yet to be able to solve my problem of DateTime sorting. What I have so far is this:

<telerik:RadGridView x:Name="tasksRadGridView"
                             RowStyleSelector="{StaticResource IsCompletedTaskStyle}"
                             SelectedItem="{Binding SelectedTask, Mode=TwoWay}"
                             ItemsSource="{Binding Tasks}"
                             Style="{StaticResource TasksGridViewStyle}">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="Subject"
                                            DataMemberBinding="{Binding Subject}"
                                            IsReadOnly="True" />
                <telerik:GridViewDataColumn Header="Date Created"
                                            UniqueName="DateCreated"
                                            IsSortable="True"
                                            DataMemberBinding="{Binding StartTime}"
                                            IsReadOnly="True" />
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

Then in my code behind I have this:

public TasksTabGridView()
        {
            InitializeComponent();
            var column = this.tasksRadGridView.Columns["DateCreated"] as GridViewDataColumn;
            if(column != null)
            {
                column.DataType = typeof (DateTime);
            }
        }

The columns are still not sorting.

Thanks,

Jonathon

2 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 21 Nov 2011, 07:46 AM
Hi,

 Can you post more info about Tasks collection and StartTime property?

All the best,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jonathon
Top achievements
Rank 1
answered on 21 Nov 2011, 07:56 PM
The Tasks collection is an interface that is being implemented by 3 different classes. The Subject is a string and the StartTime is a DateTime property that used DateTime.Now when it was stored.

Thanks,

Jonathon

[Edit]

We just updated to latest release and everything seems to work now.
Tags
GridView
Asked by
Jonathon
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Jonathon
Top achievements
Rank 1
Share this question
or