How to Display Multiple Different Property Values in a single RadGanttview Column with Tooltip

2 Answers 56 Views
GanttView
Premkumar
Top achievements
Rank 1
Iron
Premkumar asked on 07 Jul 2021, 09:51 AM

Hi Team,

We need to display the multiple different property values in a same column definition. Bind each property in seperate textblock and also have to show the tooltip with respective details. Please refer the attached screenshot, which we are looking for it.

 

Please help us to sort it.

2 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 09 Jul 2021, 12:02 PM

Hello Premkumar,

Thank you for the shared image. 

Can you check out the: How to Show Multiple Different Property Values in a single RadGanttview Column with Tooltip, forum thread where I posted a reply?

Hope this helps.

Regards,
Vladimir Stoyanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Premkumar
Top achievements
Rank 1
Iron
answered on 14 Jul 2021, 08:20 AM

Fixed Myself. Please see the below code.

Here Am using a model name 'StatusType'. and 2 converters 'GanttViewMemberBindingValueConverter' & 'GanttViewMemberBindingConverter'. 

Xaml:

<tk:ColumnDefinition
                                Width="160" 
                                IsResizable="False"
                                MemberBinding="{Binding StatusType, Converter={StaticResource GanttViewMemberBindingValueConverter}}">
                                <tk:ColumnDefinition.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                            
                                            <Border Margin="5,13,0,0" VerticalAlignment="Top" Visibility="{Binding FormattedValue, Converter={StaticResource GanttViewMemberBindingConverter}, ConverterParameter=VDR}" CornerRadius="5">
                                                <TextBlock
                                                    HorizontalAlignment="Left"
                                                    VerticalAlignment="Top"
                                                    FontWeight="DemiBold"
                                                    Foreground="#085380"
                                                    Text="{Binding FormattedValue, Converter={StaticResource GanttViewMemberBindingConverter}, ConverterParameter=DR}"
                                                    TextAlignment="Left" />
                                                <Border.ToolTip>
                                                    <ToolTip Background="Transparent">
                                                        <ToolTip.Content>
                                                            <Border
                                                                Padding="5"
                                                                 Background="#ACE5EE"
                                                                 BorderBrush="#ACE5EE"
                                                                 BorderThickness="1"
                                                                 CornerRadius="5">
                                                                <StackPanel Background="#ACE5EE">
                                                                    <TextBlock Text="Draft" Margin="0,0,0,5" Foreground="Black" FontWeight="DemiBold"/>
                                                                    <TextBlock
                                                                        HorizontalAlignment="Left"
                                                                        FontWeight="DemiBold"
                                                                        Foreground="Black"
                                                                        Text="{Binding FormattedValue, Converter={StaticResource GanttViewMemberBindingConverter}, ConverterParameter=TDR}"
                                                                        TextAlignment="Left" />
                                                                </StackPanel>
                                                            </Border>
                                                        </ToolTip.Content>
                                                    </ToolTip>
                                                </Border.ToolTip>
                                            </Border>

                                            <Border Margin="5,13,0,0" VerticalAlignment="Top" Visibility="{Binding FormattedValue, Converter={StaticResource GanttViewMemberBindingConverter}, ConverterParameter=VPE}" CornerRadius="5">
                                                <TextBlock
                                                    HorizontalAlignment="Left"
                                                    VerticalAlignment="Top"
                                                    FontWeight="DemiBold"
                                                    Foreground="#085380"
                                                    Text="{Binding FormattedValue, Converter={StaticResource GanttViewMemberBindingConverter}, ConverterParameter=PE}"
                                                    TextAlignment="Left" />
                                                <Border.ToolTip>
                                                    <ToolTip Background="Transparent">
                                                        <ToolTip.Content>
                                                            <Border
                                                                Padding="5"
                                                                 Background="#ACE5EE"
                                                                 BorderBrush="#ACE5EE"
                                                                 BorderThickness="1"
                                                                 CornerRadius="5">
                                                                <StackPanel Background="#ACE5EE">
                                                                    <TextBlock Text="Pending" Margin="0,0,0,5" Foreground="Black" FontWeight="DemiBold"/>
                                                                    <TextBlock
                                                                        HorizontalAlignment="Left"
                                                                        FontWeight="DemiBold"
                                                                        Foreground="Black"
                                                                        Text="{Binding FormattedValue, Converter={StaticResource GanttViewMemberBindingConverter}, ConverterParameter=TPE}"
                                                                        TextAlignment="Left" />
                                                                </StackPanel>
                                                            </Border>
                                                        </ToolTip.Content>
                                                    </ToolTip>
                                                </Border.ToolTip>
                                            </Border>

                                        </StackPanel>
                                    </DataTemplate>
                                </tk:ColumnDefinition.CellTemplate>
                            </tk:ColumnDefinition>

 

GanttViewMemberBindingValueConverter:

Here  merging all the string properties in to single string, properties which is in 'StatusType' Model.
public class GanttViewMemberBindingValueConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                var status = value as GanttChartCollectionProperty;
                string retval = !string.IsNullOrEmpty(status.Draft) ? status.Draft + "~" + status.DraftToolTip : string.Empty;
                retval += !string.IsNullOrEmpty(status.Pending) ? (string.IsNullOrEmpty(retval) ? string.Empty : ",") + status.Pending + "~" + status.PendingToolTip : string.Empty;
                retval += !string.IsNullOrEmpty(status.PendingModification) ? (string.IsNullOrEmpty(retval) ? string.Empty : ",") + status.PendingModification + "~" + status.PMToolTip : string.Empty;
                retval += !string.IsNullOrEmpty(status.Published) ? (string.IsNullOrEmpty(retval) ? string.Empty : ",") + status.Published + "~" + status.PublishedToolTip : string.Empty;

                return retval;
            }

            return string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

GanttViewMemberBindingConverter:

Here spliting the string based on the input parameter and returning it.
 public class GanttViewMemberBindingConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null && parameter != null)
            {
                string param = parameter.ToString();
                List<string> name = value.ToString().Split(',').ToList();
                var draftStatuses = new List<string> { "DR", "TDR", "VDR" };
                var pendingStatuses = new List<string> { "PE", "TPE", "VPE" };
                var pendingModificationStatuses = new List<string> { "PM", "TPM", "VPM" };
                var publishStatuses = new List<string> { "PU", "TPU", "VPM" };
                var status = string.Empty;

                if (draftStatuses.Contains(param))
                {
                    status = name.FirstOrDefault(x => x.Contains("Draft"));
                }
                else if (pendingStatuses.Contains(param))
                {
                    status = name.FirstOrDefault(x =>
                    x.StartsWith("Pending", StringComparison.CurrentCultureIgnoreCase) && !x.StartsWith("Pending Modification", StringComparison.CurrentCultureIgnoreCase));
                }
                else if (pendingModificationStatuses.Contains(param))
                {
                    status = name.FirstOrDefault(x => x.Contains("Pending Modification") || x.Contains("PendingModification"));
                }
                else if (publishStatuses.Contains(param))
                {
                    status = name.FirstOrDefault(x => x.Contains("Published"));
                }
                else
                {
                    return null;
                }

                return GetStatusDetails(status, param);
            }

            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
}

Vladimir Stoyanov
Telerik team
commented on 16 Jul 2021, 09:09 AM

I am glad to hear that you were able to achieve the desired result. Thank you for sharing your approach with the community. 
Tags
GanttView
Asked by
Premkumar
Top achievements
Rank 1
Iron
Answers by
Vladimir Stoyanov
Telerik team
Premkumar
Top achievements
Rank 1
Iron
Share this question
or