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

How to just show date in Start and End columns?

4 Answers 97 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Bahram
Top achievements
Rank 1
Bahram asked on 09 Oct 2019, 02:22 AM

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

4 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 11 Oct 2019, 12:04 PM

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.
0
Bahram
Top achievements
Rank 1
answered on 17 Oct 2019, 05:44 PM

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

 

0
Accepted
Vladimir Stoyanov
Telerik team
answered on 22 Oct 2019, 12:25 PM

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.
0
Bahram
Top achievements
Rank 1
answered on 23 Oct 2019, 09:32 PM

Hi Vladimir,

 

Thank you so much! It totally works now.

 

Thanks,

Bahram Afsharipoor

Tags
GanttView
Asked by
Bahram
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Bahram
Top achievements
Rank 1
Share this question
or