Sorting a DateTime Column

3 posts, 1 answers
  1. Jonathon
    Jonathon avatar
    50 posts
    Member since:
    Aug 2011

    Posted 18 Nov 2011 Link to this post

    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. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 21 Nov 2011 Link to this post

    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 >>

  3. Jonathon
    Jonathon avatar
    50 posts
    Member since:
    Aug 2011

    Posted 21 Nov 2011 Link to this post

    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.
Back to Top