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

Header menu disappears when grid has row context menu

1 Answer 65 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Reuben Russell
Top achievements
Rank 1
Reuben Russell asked on 05 May 2010, 07:45 PM
Howdy,

I'm currently encountering an issue where I'm not seeing my header context menus when I have a row context menu defined.

        <TelerikGrid:RadGridView   
            Grid.Row="2"   
            x:Name="uxGridDisplay"   
            ItemsSource="{Binding DataItemSource}"   
            DataLoaded="uxGridDisplay_DataLoaded" 
            local:ListViewHeaderContext.IsEnabled="True" 
            AutoGenerateColumns="False" 
            CanUserReorderColumns="True" 
            CanUserResizeColumns="True" 
            CanUserSelect="True" 
            CanUserFreezeColumns="True" 
            CanUserSortColumns="True" 
            IsFilteringAllowed="True" 
            GridLinesVisibility="Horizontal" 
            RowIndicatorVisibility="Collapsed" 
            SelectionMode="Extended" 
            ShowColumnHeaders="True" 
            ShowColumnFooters="True" 
            RowDetailsVisibilityMode="VisibleWhenSelected" 
            FontFamily="{StaticResource InputFontFamily}"   
            Style="{StaticResource SuperGridStyle}"    
            HeaderRowStyle="{StaticResource SuperGridHeaderRowStyle}" 
            RowStyle="{StaticResource SuperGridRowStyle}" 
            RowDetailsStyle="{StaticResource SuperGridRowDetailStyle}" 
            GroupRowStyle="{StaticResource SuperGridViewGroupRowStyle}" 
            Margin="0"   
            BorderBrush="{x:Null}"   
            BorderThickness="0" 
            Background="{StaticResource WindowBackground}" 
            Foreground="#FF2F2F2F" 
            GroupPanelForeground="White" 
            DragDrop:RadDragAndDropManager.AllowDrag="True" 
            DragDrop:RadDragAndDropManager.AllowDrop="True" 
            Exporting="uxGridDisplay_Exporting">  
 
            <TelerikNavigation:RadContextMenu.ContextMenu> 
                <TelerikNavigation:RadContextMenu Opened="RadContextMenu_Opened" ItemClick="RadContextMenu_ItemClick">  
                    <TelerikNavigation:RadContextMenu.Items> 
                        <TelerikNavigation:RadMenuItem Header="View Detail Report..." /> 
                    </TelerikNavigation:RadContextMenu.Items> 
                </TelerikNavigation:RadContextMenu> 
            </TelerikNavigation:RadContextMenu.ContextMenu> 
 
            <TelerikGrid:RadGridView.RowDetailsTemplate> 
                <DataTemplate> 
                    <TelerikGrid:RadGridView ItemsSource="{Binding LinkedItems}"   
                                             AutoGenerateColumns="False" 
                                             RowIndicatorVisibility="Collapsed" 
                                             CanUserResizeColumns="True" 
                                             CanUserFreezeColumns="False" 
                                             ShowColumnHeaders="False" 
                                             ShowGroupPanel="False" 
                                             GridLinesVisibility="Horizontal" 
                                             FontFamily="{StaticResource InputFontFamily}" 
                                             Style="{StaticResource SuperGridStyle}" 
                                             RowStyle="{StaticResource SuperGridViewRowDetailStyle}" 
                                             GroupRowStyle="{StaticResource SuperGridViewDetailGroupRowStyle}" 
                                             Margin="0"   
                                             BorderBrush="{x:Null}"   
                                             BorderThickness="0" 
                                             Background="{x:Null}" 
                                             Foreground="#FF2F2F2F">  
 
 
    
                        <TelerikGrid:RadGridView.Columns> 
                            <TelerikGrid:GridViewDataColumn DataMemberBinding="{Binding Identity}" Header="ID" Width="79" /> 
                            <TelerikGrid:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name" Width="500" TextWrapping="Wrap" /> 
                            <TelerikGrid:GridViewDataColumn DataMemberBinding="{Binding LinkedTaskRole}" Header="Link Type" Width="75" /> 
                            <TelerikGrid:GridViewDataColumn Header="Link Origin" Width="25" TextAlignment="Center">  
                                <TelerikGrid:GridViewDataColumn.CellTemplate> 
                                    <DataTemplate> 
                                        <Border Visibility="{Binding IsCustom}">  
                                            <CheckBox IsChecked="{Binding IsCustom}" IsEnabled="False" /> 
                                        </Border> 
                                    </DataTemplate> 
                                </TelerikGrid:GridViewDataColumn.CellTemplate> 
                            </TelerikGrid:GridViewDataColumn> 
                            <TelerikGrid:GridViewDataColumn DataMemberBinding="{Binding LinkType}" Header="Link Logic" Width="100" TextAlignment="Center" /> 
                            <TelerikGrid:GridViewDataColumn Header="Link Lag" Width="100">  
                                <TelerikGrid:GridViewDataColumn.CellTemplate> 
                                    <DataTemplate> 
                                        <StackPanel Orientation="Horizontal">  
                                            <TextBlock Text="Lag:" Foreground="{Binding LinkLag}" Margin="0,0,3,0"/>  
                                            <TextBlock Text="{Binding LinkLag}"/>  
                                            <TextBlock Text="hrs" Foreground="{Binding LinkLag}"/>  
                                        </StackPanel> 
                                    </DataTemplate> 
                                </TelerikGrid:GridViewDataColumn.CellTemplate> 
                            </TelerikGrid:GridViewDataColumn> 
                        </TelerikGrid:RadGridView.Columns> 
                          
                        <TelerikGrid:RadGridView.GroupDescriptors> 
                            <TelerikData:GroupDescriptor Member="DataType">  
                                <TelerikData:GroupDescriptor.AggregateFunctions> 
                                    <TelerikData:CountFunction Caption="Total:" /> 
                                </TelerikData:GroupDescriptor.AggregateFunctions> 
                            </TelerikData:GroupDescriptor> 
                        </TelerikGrid:RadGridView.GroupDescriptors> 
                    </TelerikGrid:RadGridView> 
                </DataTemplate>                  
            </TelerikGrid:RadGridView.RowDetailsTemplate> 
              
        </TelerikGrid:RadGridView> 

       private void RadContextMenu_ItemClick(object sender, RadRoutedEventArgs e)  
        {  
            RadContextMenu menu = (RadContextMenu)sender;  
            RadMenuItem clickedItem = e.OriginalSource as RadMenuItem;  
            GridViewRow row = menu.GetClickedElement<GridViewRow>();  
 
            if (clickedItem != null && row != null)  
            {  
                string header = Convert.ToString(clickedItem.Header);  
                string url;  
                switch (header)  
                {  
                    case "View Detail Report...":  
                        // Get the id out of the row.  
                        // Code removed  
                        break;  
                }  
            }  
        }  
 
        private void RadContextMenu_Opened(object sender, RoutedEventArgs e)  
        {  
            RadContextMenu menu = (RadContextMenu)sender;  
            GridViewRow row = menu.GetClickedElement<GridViewRow>();  
 
            if (row != null)  
            {  
                row.IsSelected = row.IsCurrent = true;  
                GridViewCell cell = menu.GetClickedElement<GridViewCell>();  
                if (cell != null)  
                {  
                    cell.IsCurrent = true;  
                }  
            }  
            else  
            {  
                menu.IsOpen = false;  
            }  
        } 

1 Answer, 1 is accepted

Sort by
0
Reuben Russell
Top achievements
Rank 1
answered on 05 May 2010, 10:37 PM
Never mind.  Figured out the problem, the declarative menu was overriding the header menu.
Tags
GridView
Asked by
Reuben Russell
Top achievements
Rank 1
Answers by
Reuben Russell
Top achievements
Rank 1
Share this question
or