GridViewDataColumn Tooltip

16 posts, 1 answers
  1. Rogério
    Rogério avatar
    33 posts
    Member since:
    Feb 2009

    Posted 13 Mar 2009 Link to this post

    Hello,

    I'm trying to define a GridViewColumn Tooltip, but without any success so far! I already tried to use ToolTipService.Tooltip to specify a TextBlock by code, but nothing is displayed!

    Any suggestion?

    Thanks.

    Regards,
    Rogério
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 16 Mar 2009 Link to this post

    Hello Rogério,

    If you want tooltip for every cell in specific column you can use the approach from this demo:

     <Controls:GridViewColumn Width="*"  HeaderText="Product Logo (Unbound)">
                        <Controls:GridViewColumn.CellStyle>
                            <Style TargetType="telerikGridView:GridViewCell">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="telerikGridView:GridViewCell">
                                            <Border ToolTipService.ToolTip="{Binding ImageUrl}" BorderThickness="{TemplateBinding BorderThickness}"
                                                BorderBrush="{TemplateBinding BorderBrush}"
                                                Background="{TemplateBinding Background}">
                                                <HyperlinkButton TargetName="_blank" NavigateUri="{Binding Url}">
                                                    <Image Source="{Binding ImageUrl, Converter={StaticResource converter}}" />
                                                </HyperlinkButton>
                                            </Border>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Controls:GridViewColumn.CellStyle>
                    </Controls:GridViewColumn>

    Regards,
    Vlad
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Rogério
    Rogério avatar
    33 posts
    Member since:
    Feb 2009

    Posted 16 Mar 2009 Link to this post

    Sorry, but I cannot see any ToolTip displayed on the sample that you suggested!!

    I was talking about displaying a ToolTip, only, for the columns Header, not for the Cell.

    Regards,
    Rogério
  4. Answer
    Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 18 Mar 2009 Link to this post

    Hello Rogério,


    Here is some sample code to programmatically assign a tooltip text to the header cells.
    I believe there is also a XAML based way but it would require to modify the 'fat" xaml template of the header cell. So I think the best solution for your scenario is something like:
    public Page()  
            {  
                InitializeComponent();  
                this.TestGridView.RowLoaded += new EventHandler<RowLoadedEventArgs>(TestGridView_RowLoaded);  
                  
            }  
     
            void TestGridView_RowLoaded(object sender, RowLoadedEventArgs e)  
            {  
                if(e.Row is GridViewHeaderRow)  
                {  
                    GridViewHeaderRow headerRow = e.Row as GridViewHeaderRow;  
                    foreach (GridViewHeaderCell cell in headerRow.Items)  
                    {  
                        cell.SetValue(ToolTipService.ToolTipProperty,"test tooltip");  
                    }  
                }  
            } 

    I am aware this is a kind of Winforms approach but it will do the job. Meanwhile we are doing our best to provide easy and declarative way to achieve such tasks for our future releases.

    Best wishes,
    Pavel Pavlov
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Celeste
    Celeste avatar
    34 posts
    Member since:
    May 2009

    Posted 28 Sep 2009 Link to this post

    I would like to know if with last dlls for Silverlight 3, exists a better way to do this.

    Thanks

    Celeste.
  6. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 29 Sep 2009 Link to this post

    Hi Celeste,

    We have added a Header property to the column. You may set the header to any visual you want . For example you may set the Header to a TextBlock to display the column name and set the desired  tooltip to this textblock .
    Let me know if you find troubles implementing this.

    All the best,
    Pavel Pavlov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Celeste
    Celeste avatar
    34 posts
    Member since:
    May 2009

    Posted 29 Sep 2009 Link to this post

    Thanks!
    I' ve tried what you explain in the answer and it worked.

    But I am having problem with gridviewcolumns that I am creating by code and adding to gridview, because throws an exception.

                    
                    while (condition)
                    {
                    column = 
    new GridViewDataColumn();  
                    TextBlock header_t = new TextBlock();  
                    header_t.Text = col.TITLE;  
                    ToolTipService.SetToolTip(header_t, "test MCM");  
                    column.Header = header_t;  
                    .....  
                    gridview.Columns.Add(column);  
                    }
     


    It throws an exception in gridview.Columns.Add in the second iteration. If I comment:

                    TextBlock header_t = new TextBlock();     
                    header_t.Text = col.TITLE;     
                    ToolTipService.SetToolTip(header_t, "test MCM");  
     
    everythings works.


    'The element is already the child of another element'...


    System.Windows.Markup.XamlParseException was unhandled by user code 
      Message=" [Line: 0 Position: 0]\r\n   --- Inner Exception ---\r\nEl elemento ya es un objeto secundario de otro elemento.\r\n" 
      LineNumber=0  
      LinePosition=0  
      StackTrace:  
           en MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)  
           en MS.Internal.XcpImports.MethodEx(DependencyObject obj, String name)  
           en MS.Internal.XcpImports.FrameworkElement_ApplyTemplate(FrameworkElement frameworkElement)  
           en System.Windows.FrameworkElement.ApplyTemplateInternal()  
           en System.Windows.Controls.Control.ApplyTemplate()  
           en Telerik.Windows.Controls.GridView.GridViewDataControl.<PopulateHeaderAndFooterRows>b__45(GridViewCellBase c)  
           en System.Collections.Generic.List`1.ForEach(Action`1 action)  
           en Telerik.Windows.Controls.GridView.GridViewDataControl.PopulateHeaderAndFooterRows()  
           en Telerik.Windows.Controls.GridView.GridViewDataControl.OnColumnsCollectionChanged(NotifyCollectionChangedEventArgs e)  
           en Telerik.Windows.Controls.GridViewColumnCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)  
           en System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)  
           en Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)  
           en System.Collections.ObjectModel.Collection`1.Add(T item)  
           en Silverlight.Common.Page.ReorderAllColumns(RadGridView gridView, ObservableCollection`1 lista)  
           en Cupos.ABMSolEnt.<NewComprobante>b__0()  
      InnerException: System.InvalidOperationException  
           Message="El elemento ya es un objeto secundario de otro elemento." 
           StackTrace:  
                en MS.Internal.XcpImports.CheckHResult(UInt32 hr)  
                en MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, DependencyObject doh)  
                en MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper doh, DependencyProperty property, Object obj)  
                en System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)  
                en System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle, PropertyInvalidationReason reason)  
                en System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)  
                en System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)  
                en System.Windows.Controls.ContentControl.set_Content(Object value)  
                en Telerik.Windows.Controls.GridView.GridViewHeaderCell.SetHeaderText()  
                en Telerik.Windows.Controls.GridView.GridViewHeaderCell.OnApplyTemplate()  
                en System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)  
           InnerException:   
     







  8. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 02 Oct 2009 Link to this post

    Hi Celeste,

    We had such known issue with headers. Can you please download the latest internal build and give it a try. I believe it has been fixed and switching to the newer dills should help here.

    Greetings,
    Pavel Pavlov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. Celeste
    Celeste avatar
    34 posts
    Member since:
    May 2009

    Posted 05 Oct 2009 Link to this post

    The issue was fixed!
    Thanks.
  10. Scott
    Scott avatar
    42 posts
    Member since:
    Feb 2009

    Posted 07 Jul 2010 Link to this post

    Hi Pavel,

    I'm trying your approach to adding tooltips to GridViewDataColumn column header cells. I'm using  RadControls_for_Silverlight_4_2010_1_0422_TRIAL version of the controls. My problem is that GridViewHeaderRow.Cells returns only one GridViewHeaderCel despite the fact that I have 7 columns in the grid. The tooltip on the first column gets set as expected, but the remaining six columns are never processed by the foreach loop.

    How can I set tooltips on the remaining column headings?

    My XAML is:
                    <telerikControls:RadGridView x:Name="permissionsGridView" 
                                                 Grid.Row="1" 
                                                 Background="{StaticResource DetailAreaBackgroundBrush}" 
                                                 ShowGroupPanel="False" 
                                                 ItemsSource="{Binding Mode=OneWay}" 
                                                 AutoGenerateColumns="False" 
                                                 IsReadOnly="{Binding Path=Current.User.CanUpdate, Mode=OneWay, Converter={StaticResource NotOperatorConverter}, Source={StaticResource WebContext}}" 
                                                 CanUserFreezeColumns="False" 
                                                 CanUserReorderColumns="False" 
                                                 CanUserSortColumns="True" 
                                                 CanUserInsertRows="False" 
                                                 CanUserDeleteRows="False" 
                                             > 
                        <telerikControls:RadGridView.SortDescriptors> 
                            <telerikData:SortDescriptor Member="ModuleName" /> 
                        </telerikControls:RadGridView.SortDescriptors> 
                         
                        <telerikControls:RadGridView.Columns> 
                            <!-- Module Names--> 
                            <telerikControls:GridViewDataColumn Header="Module"  DataMemberBinding="{Binding Path=ModuleName, Mode=OneWay}" /> 
     
                            <!-- Permissions --> 
                            <telerikControls:GridViewDataColumn Header="Create" > 
                                <telerikControls:GridViewDataColumn.CellTemplate> 
                                    <DataTemplate> 
                                        <CheckBox IsChecked="{Binding srmp_cancreate, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center" /> 
                                    </DataTemplate> 
                                </telerikControls:GridViewDataColumn.CellTemplate> 
                            </telerikControls:GridViewDataColumn> 
     
                            <telerikControls:GridViewDataColumn Header="Read"
                                <telerikControls:GridViewDataColumn.CellTemplate> 
                                    <DataTemplate> 
                                        <CheckBox IsChecked="{Binding srmp_canread, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center" /> 
                                    </DataTemplate> 
                                </telerikControls:GridViewDataColumn.CellTemplate> 
                            </telerikControls:GridViewDataColumn> 
     
                            <telerikControls:GridViewDataColumn Header="Update" > 
                                <telerikControls:GridViewDataColumn.CellTemplate> 
                                    <DataTemplate> 
                                        <CheckBox IsChecked="{Binding srmp_canupdate, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center" /> 
                                    </DataTemplate> 
                                </telerikControls:GridViewDataColumn.CellTemplate> 
                            </telerikControls:GridViewDataColumn> 
     
                            <telerikControls:GridViewDataColumn Header="Delete"
                                <telerikControls:GridViewDataColumn.CellTemplate> 
                                    <DataTemplate> 
                                        <CheckBox IsChecked="{Binding srmp_candelete, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center" /> 
                                    </DataTemplate> 
                                </telerikControls:GridViewDataColumn.CellTemplate> 
                            </telerikControls:GridViewDataColumn> 
     
                            <telerikControls:GridViewDataColumn Header="Forward"
                                <telerikControls:GridViewDataColumn.CellTemplate> 
                                    <DataTemplate> 
                                        <CheckBox IsChecked="{Binding srmp_canforward, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center"/> 
                                    </DataTemplate> 
                                </telerikControls:GridViewDataColumn.CellTemplate> 
                            </telerikControls:GridViewDataColumn> 
     
                            <telerikControls:GridViewDataColumn Header="See All"
                                <telerikControls:GridViewDataColumn.CellTemplate> 
                                    <DataTemplate> 
                                        <CheckBox IsChecked="{Binding srmp_canseeall, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center"/> 
                                    </DataTemplate> 
                                </telerikControls:GridViewDataColumn.CellTemplate> 
                            </telerikControls:GridViewDataColumn> 
     
                        </telerikControls:RadGridView.Columns> 
     
                    </telerikControls:RadGridView> 




    Code behind is:
        public partial class SecurityRoleDetailView : ISecurityRoleDetailView 
        { 
            public SecurityRoleDetailView(ISecurityRoleDetailViewModel viewModel) 
            { 
                if (viewModel == null
                { 
                    throw new ArgumentNullException("viewModel"); 
                } 
                InitializeComponent(); 
                DataContext = viewModel; 
                permissionsGridView.RowLoaded += PermissionsGridViewRowLoadedHandler; 
            } 
     
            private void PermissionsGridViewRowLoadedHandler(object sender, RowLoadedEventArgs e) 
            { 
                if (e.Row is GridViewHeaderRow) 
                { 
                    GridViewHeaderRow headerRow = e.Row as GridViewHeaderRow; 
                    foreach (GridViewHeaderCell headerCell in headerRow.Cells) 
                    { 
                        headerCell.SetValue(ToolTipService.ToolTipProperty, "Test Tooltip"); 
                    } 
                } 
            } 
        } 

    What am I missing?
    Thanks,
    Scott


  11. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 08 Jul 2010 Link to this post

    Hi,

     You can set EnableColumnVirtualization to false to avoid this.

    Regards,
    Vlad
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. Scott
    Scott avatar
    42 posts
    Member since:
    Feb 2009

    Posted 08 Jul 2010 Link to this post

    Hi Vlad,

    Works perfectly--thanks for the outstanding support.

    Scott.
  13. Naseem
    Naseem avatar
    70 posts
    Member since:
    Nov 2010

    Posted 16 Nov 2010 Link to this post

    Hi,

    I'm using the latest version of RadControl and I need to set tooltip for GridViewColumn in a way the column bind to a feild and the tooltip bind to another feild .

    by using silverlight datagrid ,here was how I implemeted it:

     

    <data:DataGridTemplateColumn Header="Filter">
        <data:DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Description}" ToolTipService.ToolTip="{Binding FilterHint}" Width="100" Margin="0,5"/>
            </DataTemplate>
        </data:DataGridTemplateColumn.CellTemplate>
    </data:DataGridTemplateColumn>

     

     

    In telerik ,I have tried this and it didn't work

     

     

    <GridView:GridViewDataColumn Header="Filter" Width="230" DataMemberBinding="{Binding Description}"  IsReadOnly="True">
                        <GridView:GridViewDataColumn.ToolTipTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <TextBlock Text="{Binding FilterHint}" Width="100" Margin="0,5"/>
                                </StackPanel>
                            </DataTemplate>
                        </GridView:GridViewDataColumn.ToolTipTemplate>
    </GridView:GridViewDataColumn>

     


    Actually I have realized when both GridViewColumn and textBlock bind to one field ,it working . but I need it to bind them to different fileds.

    I appreciate your help,

    Thank you

  14. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 17 Nov 2010 Link to this post

    Hi,

     Have you tried the CellTemplate approach with our grid as well? 

    Regards,
    Vlad
    the Telerik team
    See What's New in RadControls for Silverlight in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
  15. Victor
    Victor avatar
    4 posts
    Member since:
    Oct 2010

    Posted 17 Nov 2010 Link to this post

    Hi,

    It's working :)

    Thank you
  16. Shawn
    Shawn avatar
    1 posts
    Member since:
    Jan 2012

    Posted 20 Jan 2012 Link to this post

    Hi,
    I am trying to get the grid view column tooltip to work and none of the solutions from this post were helpful.


    ValidatedInfo is an observable collection of a class(private ObservableCollection<ValidatedCounterReportInfo> ValidatedInfo;) and each column in the grid is associated to a property.
    The data displays fine in the grid and everything else works as expected but none of the tooltips are showing up.


    Below is the WPF code:
    xmlns:TelerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"

    Can you help me understand the problem here.


    Thanks
    SN

    <TelerikInput:RadGridView ItemsSource="{Binding ValidatedInfo}"
                              SelectionMode="Extended"
                              SelectedItem="{Binding Path=SelectedCell, Mode=TwoWay}"
                              Grid.Row="2"
                              Grid.Column="0"
                              Grid.ColumnSpan="4"
                              IsReadOnly="True"
                              RowIndicatorVisibility="Collapsed"
                              AutoGenerateColumns="False"
                              CanUserFreezeColumns="False"
                              Margin="5"
                              ActionOnLostFocus="None"
                              ShowGroupPanel="False"
                              KeyboardNavigation.AcceptsReturn="True"
                              EnableColumnVirtualization="False">
      <TelerikInput:RadGridView.Columns>
        <TelerikInput:GridViewDataColumn Width="200"
                                    DataMemberBinding="{Binding FileName}"
                                    EditTriggers="CellClick"
                                    ToolTipService.ToolTip="{Binding FileName}"
                                    Header="File Name"/>
        <TelerikInput:GridViewDataColumn Width="60"
                                    DataMemberBinding="{Binding Type}"
                                    EditTriggers="CellClick"
                                    ToolTipService.ToolTip="{Binding Type}"
                                    Header="Type"/>
        <TelerikInput:GridViewDataColumn Width="60"
                                    DataMemberBinding="{Binding Valid}"
                                    ToolTipService.ToolTip="{Binding Valid}"
                                    Header="Valid">
                                    <TelerikInput:GridViewDataColumn.CellTemplate>
                                      <DataTemplate>
                                        <TextBox Text="{Binding Valid, Converter={StaticResource booleanConverter}}"
                                                 Foreground="White"
                                                 Background="{Binding Valid, Converter={StaticResource backgroundConverter}}"/>
                                      </DataTemplate>
                                    </TelerikInput:GridViewDataColumn.CellTemplate>
        </TelerikInput:GridViewDataColumn>
        <TelerikInput:GridViewDataColumn Width="160"
                                    DataMemberBinding="{Binding Details}"
                                    ToolTipService.ToolTip="{Binding Details}"
                                    EditTriggers="CellClick"
                                    Header="Details"/>
      </TelerikInput:RadGridView.Columns>
    </TelerikInput:RadGridView>
Back to Top