How to just show date in Start and End columns?

5 posts, 1 answers
  1. Bahram
    Bahram avatar
    24 posts
    Member since:
    Feb 2019

    Posted 08 Oct 2019 Link to this post

    Hi there,

     

    Is there anyway to get rid of time and just show date (ex: 10/08/2019) in Start and End columns? I don't need to see time, I just want to see date.

    Please assist me.

     

     

    Thanks,

    Bahram Afsharipoor

  2. Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    707 posts

    Posted 11 Oct 2019 Link to this post

    Hello Bahram,

    In order to achieve what you are going for you can use a CellTemplate along with an IValueConverter. Here is what I have in mind:

     <telerik:ColumnDefinition Header="Start" MemberBinding="{Binding Start}">
                        <telerik:ColumnDefinition.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding FormattedValue, Converter={StaticResource Converter}}" VerticalAlignment="Center" />
                            </DataTemplate>
                        </telerik:ColumnDefinition.CellTemplate>
    </telerik:ColumnDefinition>
    public class Converter : IValueConverter
        {
            public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
            {
                var date = value.ToString();
    
                var parts = date.Split(new char[] { ' ' });
                return parts[0];
            }
    
            public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
            {
                throw new NotImplementedException();
            }
        }

    I hope you find this helpful.

    Regards,
    Vladimir Stoyanov
    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.
  3. Bahram
    Bahram avatar
    24 posts
    Member since:
    Feb 2019

    Posted 17 Oct 2019 in reply to Vladimir Stoyanov Link to this post

    Hi Vladimir,

     

    Thank you for giving me the above solution, but your sample works only for CellTemplate not CellEditTemplate. My start and end dates are in edit mode as you see below:

     

    <telerik:ColumnDefinition MemberBinding="{Binding Start}" Header="Start" Width="AutoHeaderAndContent">
        <telerik:ColumnDefinition.CellEditTemplate>
             <DataTemplate>
                   <telerik:RadDatePicker SelectedValue="{Binding Start, Mode=TwoWay,
                                              Converter={StaticResource Converter}}"/>
             </DataTemplate>
        </telerik:ColumnDefinition.CellEditTemplate>
    </telerik:ColumnDefinition>
    <telerik:ColumnDefinition MemberBinding="{Binding End}" Header="End" Width="AutoHeaderAndContent">
         <telerik:ColumnDefinition.CellEditTemplate>
              <DataTemplate>
                    <telerik:RadDatePicker SelectedValue="{Binding End, Mode=TwoWay,
                                              Converter={StaticResource Converter}}"/>
              </DataTemplate>
         </telerik:ColumnDefinition.CellEditTemplate>
    </telerik:ColumnDefinition>

     

    Therefore, while I am editing date, it shows only date correctly (attached picture 1)

    However, after date is edited, it will show both date and time again! (attached picture 2)

     

     

    Thanks,

    Bahram Afsharipoor

     

  4. Answer
    Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    707 posts

    Posted 22 Oct 2019 Link to this post

    Hello Bahram,

    Thank you for the provided pictures. 

    Can you make sure to define both the CellTemplate and the CellEditTemplate? I am attaching a sample project demonstrating what I have in mind.

    Please, check it out and let me know, if that is what you were going for. 

    Regards,
    Vladimir Stoyanov
    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.
  5. Bahram
    Bahram avatar
    24 posts
    Member since:
    Feb 2019

    Posted 23 Oct 2019 in reply to Vladimir Stoyanov Link to this post

    Hi Vladimir,

     

    Thank you so much! It totally works now.

     

    Thanks,

    Bahram Afsharipoor

Back to Top