Telerik Forums
UI for WPF Forum
1 answer
597 views
I need to have a context menu on a grid whereby I can determine which column the user right-clicked on. I create the columns dynamically with the following code:

        private void CreateNewColumn(FieldDescriptor fd, uint fieldno) { 
            fieldGrid.Columns.Add(new GridViewDataColumn() { 
                UniqueName = fd.fieldName, 
                Header = fd.displayName, 
                DataMemberBinding = new Binding("Fields[" + fieldno + "]"), 
                ContextMenu = new ContextMenu() { 
                    Items = { 
                        new MenuItem() { 
                            Header = "Field Properties"
                            Command = Commands.FieldProperties, 
                            CommandBindings = { new CommandBinding(Commands.FieldProperties, FieldProperties_Execute) }  
                        }, 
                        new MenuItem() { 
                            Header = "Delete Field"
                            Command = Commands.DeleteField, 
                            CommandBindings = { new CommandBinding(Commands.DeleteField, DeleteField_Execute) } 
                        } 
                    } 
                } 
            }); 
        } 

Unfortunately the popup menu never appears when I right click anywhere on the grid. If I bind the context menu to the grid (i.e. fieldGrid.ContextMenu = new ContextMenu() {...) then the menu pops up, but I have no way to tell what column was clicked. Is there a way to make this work?

Thanks,
Ferruccio


Vlad
Telerik team
 answered on 12 Jan 2010
4 answers
290 views
Hi Team,

I have a Parent Grid In my page,
Its having hierarchical (projects >> tasks >> comments) data.
My Task grid contains 3 Tab items

I can able to load Tasks  GridView (first tab grid).
But second and third tab grid data are not loaded
Always shows empty GridView

cs page

ProjTasks = GetData(); 
if (outlookProjTasks != null) 
            { 
                GridViewTableDefinition detail1 = new GridViewTableDefinition(); 
                detail1.Relation = new PropertyRelation("Tasks"); 
                detail1.Relation.Name = "Tasks"
 
                GridViewTableDefinition detail2 = new GridViewTableDefinition(); 
                detail2.Relation = new PropertyRelation("ActiveTasks"); 
                detail2.Relation.Name = "ActiveTasks"
 
                GridViewTableDefinition detail3 = new GridViewTableDefinition(); 
                detail3.Relation = new PropertyRelation("CompletedTasks"); 
                detail3.Relation.Name = "CompletedTasks"
 
                this.GrdProjectTasks.TableDefinition.ChildTableDefinitions.Add(detail1); 
                this.GrdProjectTasks.TableDefinition.ChildTableDefinitions.Add(detail2); 
                this.GrdProjectTasks.TableDefinition.ChildTableDefinitions.Add(detail3); 
 
                this.GrdProjectTasks.RowDetailsVisibilityMode = Telerik.Windows.Controls.GridView.GridViewRowDetailsVisibilityMode.VisibleWhenSelected; 
                this.GrdProjectTasks.ItemsSource = ProjTasks
            } 

XAML File

<Grid.Resources> 
            <my:FormattingConverter x:Key="formatter" /> 
            <!--<telerik:RadGridView x:Key="DataSource"/>--> 
            <Style TargetType="telerik:ChildDataControlsPresenter"
                <Setter Property="Template"
                    <Setter.Value> 
                        <ControlTemplate TargetType="telerik:ChildDataControlsPresenter"
                            <TabControl> 
                                <TabItem  Header="All Tasks"
                                    <telerik:RadGridView x:Name="radGridView1" RowLoaded="radGridView1_RowLoaded" LoadingRowDetails="radGridView1_LoadingRowDetails" Height="Auto"  
                                    ShowGroupPanel="True" Margin="0,0,0,0" RowIndicatorVisibility="Collapsed" CanUserFreezeColumns="False" AutoGenerateColumns="True" FontFamily="Segoe UI" FontSize="11" FontStretch="5"
                                        <telerik:RadGridView.Columns> 
                                            <telerik:GridViewToggleRowDetailsColumn /> 
                                        </telerik:RadGridView.Columns> 
                                    </telerik:RadGridView> 
                                </TabItem> 
                                <TabItem Header="Active Tasks"
                                    <telerik:RadGridView x:Name="grdActiveTasks" Height="200" ShowGroupPanel="True" Margin="0,0,0,0" RowIndicatorVisibility="Collapsed"  
                                            CanUserFreezeColumns="False" AutoGenerateColumns="True" FontFamily="Segoe UI" FontSize="11" FontStretch="5" ItemsSource="{Binding ActiveTasks}"
                                    </telerik:RadGridView> 
                                    <!--ItemsSource="{Binding MasterRecord.Data.ActiveTasks}"--> 
                                </TabItem> 
                                <TabItem Header="Completed Tasks"
                                    <telerik:RadGridView x:Name="grdCompletedTasks" Height="200" ShowGroupPanel="True" Margin="0,0,0,0" RowIndicatorVisibility="Collapsed" 
                                            CanUserFreezeColumns="False" AutoGenerateColumns="True" FontFamily="Segoe UI" FontSize="11" FontStretch="5" ItemsSource="{Binding Tasks}"
                                        <telerik:RadGridView.Columns> 
                                            <telerik:GridViewDataColumn DataMemberBinding="{Binding Subject}" Header="Subject"/> 
                                        </telerik:RadGridView.Columns> 
                                    </telerik:RadGridView> 
                                    <!--ItemsSource="{Binding MasterRecord.Data.CompletedTasks}"--> 
                                </TabItem> 
                            </TabControl> 
 
                        </ControlTemplate> 
                    </Setter.Value> 
                </Setter> 
            </Style> 
            <Style x:Key="GridViewAlternateRowStyle" TargetType="telerik:GridViewRow"
                <Setter Property="Background" Value="#303030" /> 
                <Setter Property="Foreground" Value="White" /> 
                <Setter Property="BorderThickness" Value="1" /> 
                <Setter Property="BorderBrush" Value="Black" /> 
            </Style> 
 
            <Style x:Key="GridViewRowStyle" TargetType="telerik:GridViewRow"
                <Setter Property="Background" Value="#606060" /> 
                <Setter Property="Foreground" Value="White" /> 
                <Setter Property="BorderThickness" Value="1" /> 
                <Setter Property="BorderBrush" Value="Black" /> 
            </Style> 
        </Grid.Resources> 
 
 <telerik:RadGridView Margin="1,60,0,0" RowIndicatorVisibility="Collapsed" IsFilteringAllowed="True"  Name="GrdProjectTasks" FontFamily="Segoe UI" FontSize="11" FontStretch="5" 
            UseAlternateRowStyle="True" ShowGroupPanel="True" CanUserFreezeColumns="False" IsReadOnly="True" RowLoaded="GrdProjectTasks_RowLoaded" 
            DataLoadMode="Asynchronous" RowStyle="{StaticResource GridViewRowStyle}" AlternateRowStyle="{StaticResource GridViewAlternateRowStyle}" GroupPanelBackground="#FF202020"  
            CanUserSortColumns="False" BorderThickness="0" Grid.Column="1" Height="740" Width="1024" Grid.ColumnSpan="2"
            <!--my:GridViewFilterRow.IsEnabled="True"--> 
        </telerik:RadGridView> 


Can you please help on this issue

Regards
Shanthi

shadhan
Top achievements
Rank 1
 answered on 12 Jan 2010
0 answers
99 views
Hello,
     When a column on the grid is re-ordered there appears to be only the DisplayIndexMap object in the grid to keep track of the new order. This object is protected so I cannot get at it directly. Since I could not figure out how to determine the new order on the grid side I changed the column order of the datatable to match the grid's.

In the ColumnDisplayIndexChanged event of the grid I added this line of code, which takes care of the re-ordering:

<datatable name>.Columns[e.Column.Header.ToString()].SetOrdinal(e.Column.DisplayIndex);

This event will be triggered twice. Once for the column that was moved and again for the column that was shifted over for the moved column.

When I print the contents of the grid I use the datatable as the data source.


Jorge Gonzalez
Top achievements
Rank 1
 asked on 11 Jan 2010
0 answers
103 views
Hello,
    I finally figured out how to filter a grid associated with a datatable. Instead of filtering the grid, which was a traumatic experience, I filtered the datatable associated with the grid instead. It took less than 7 lines of code and most of those lines of code were for creating the filter expression:

I am collecting a bunch of values in another window so I can filter the varnames column in my grid so:

string filterexpression = "varnames in (" + < bunch of values> + ")"
gridname.ItemsSource = <datatable name>.Select(filterexpression, <supply sort expression>, DataViewRowState.CurrentRows);

Jorge Gonzalez
Top achievements
Rank 1
 asked on 11 Jan 2010
3 answers
108 views
Hello,

I would like to evaluate wether a Drop Operation on a specfic RadtreeViewItem is allowed.
I got a WPF Radtreeview with hierachical Data Binding, Multiselection and Drag&Drop occurs only within the Treeview.
Therefore I added a Event Handler to the DropQuery Event of the RadTreeview.

RadTreeView1.AddHandler(RadDragAndDropManager.DropQueryEvent, new EventHandler&lt;DragDropQueryEventArgs&gt;(RadTreeView_DropQuery), true); 


For my Decision it is necessary to know which RadtreeviewItems are dragged. I don´t need the dragged data objects, because my decision is based on parent of each dragged RadtreeviewItem.

 
private void RadTreeView_DropQuery(object sender, DragDropQueryEventArgs e) 
        { 
 
            bool dropPossible = checkIfDropPossible(draggedRadTreeViewItems); 
            
            if (dropPossible) 
            { 
                e.QueryResult = true
            } 
            else 
            { 
                e.QueryResult = false
            } 
}                     


Therefore I need a way to get the dragged RadtreeviewItems in the DropQueryEvent. I searched all e.Options members but I get the responding data objects (e.Options.Payload) only.

How can I get corresponding dragged RadTreeViewItems to the DataObjects in the DropQueryEvent? Any help is welcome.

Best Regards
Akiono Wan
Valentin.Stoychev
Telerik team
 answered on 11 Jan 2010
4 answers
83 views
Hi,

I'm using RadTreeView control for WPF Q2 2009, with values

IsOptionElementsEnabled

 

="True"  

 

ItemsOptionListType="CheckList"  

 

IsTriStateMode="True"

the treeview is collapsed. If i check first root item but not expand the node, CheckedItems only return one item. Otherwise if I expand the node, CheckedItems returns the root item node and subitems.

Is there any option to avoid that?

This is the example:

 

<telerik:RadTreeView   
            IsLineEnabled="True"   
            IsOptionElementsEnabled="True" 
            ItemsOptionListType="CheckList"    
            IsTriStateMode="True" 
            IsRootLinesEnabled="True"    
 
            controls:StyleManager.Theme="Vista" 
        > 
            <telerik:RadTreeViewItem Header="Item0">  
                <telerik:RadTreeViewItem Header="Item1.1"/>  
                <telerik:RadTreeViewItem Header="Item1.2"/>  
            </telerik:RadTreeViewItem> 
            <telerik:RadTreeViewItem Header="Item1">  
                <telerik:RadTreeViewItem Header="Item1.1"/>  
                <telerik:RadTreeViewItem Header="Item1.2"/>  
            </telerik:RadTreeViewItem> 
            <telerik:RadTreeViewItem Header="Item2">  
                <telerik:RadTreeViewItem Header="Item1.1"/>  
                <telerik:RadTreeViewItem Header="Item1.2"/>  
            </telerik:RadTreeViewItem> 
 
        </telerik:RadTreeView> 

When I check node Item0 but not expand it, CheckedItems returns Item 0 only (this happens only the first time node is collapsed)
But expanding it, CheckedItems returns Item 0, Item1.1, Item1.2. (if i collapsed the node again, CheckedItems returns Item 0, Item1.1, Item1.2)

 

Also I set theme to Vista (controls:

StyleManager.Theme="Vista" ) but I get an orange backgound when mouse is over the nodes. Is this ok?

Thanks and best regards,
Alberto

 

 

question_forum
Top achievements
Rank 1
 answered on 11 Jan 2010
2 answers
149 views
In the method signature for the event handler for the event 'Edited' there are the following parameters: ( object sender, RadTreeViewItemEditedEventArgs e ).

How can I get the RadTreeViewItem that is being edited? e.OriginalSource returns an 'EditableHeaderedItemsControl' and sender returns the RadTreeView. Is there something I am missing?

Thank you.

EDIT:

OK, I was able to cast e.OriginalSource to RadTreeViewItem. The problem that I am encountering is that I want to delete the node if its header is empty. So inside the Edited event handler I have the following code:

item.ParentItem.Items.Remove(item); 

I get the following null exception:

   at Telerik.Windows.Controls.RadTreeViewItem.CommitEdit() in c:\Builds\WPF_Scrum\Navigation_WPF\Sources\Development\Controls\Navigation\TreeView\RadTreeViewItem.cs:line 718
   at Telerik.Windows.Controls.RadTreeView.HandleItemSelectionFromUI(RadTreeViewItem treeViewItemToSelect) in c:\Builds\WPF_Scrum\Navigation_WPF\Sources\Development\Controls\Navigation\TreeView\RadTreeView.cs:line 2196
   at Telerik.Windows.Controls.RadTreeViewItem.OnHeaderMouseLeftButtonDown(Object sender, MouseButtonEventArgs e) in c:\Builds\WPF_Scrum\Navigation_WPF\Sources\Development\Controls\Navigation\TreeView\RadTreeViewItem.Events.cs:line 790
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.UIElement.CrackMouseButtonEventAndReRaiseEvent(DependencyObject sender, MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Window.ShowHelper(Object booleanBox)
   at System.Windows.Window.Show()
   at System.Windows.Window.ShowDialog()


Ziad
Top achievements
Rank 1
 answered on 11 Jan 2010
7 answers
106 views
I have a project that I'm deving from scratch.

SQL database
wpf and web
stock/inventory  - ordering, tracking

anybody interested in helping me out..  
Vlad
Telerik team
 answered on 11 Jan 2010
1 answer
80 views
I want to initiate sort on the grid from code.  I am not having success.

This is what I've tried:

gvDocumentListing.Columns[4].SortingState = Telerik.Windows.Controls.SortingState.Descending;

 

gvDocumentListing.Rebind();



This does not work.  I saw in an earlier post that some one called Columns.Reset().    This method appears to have been removed.
Vlad
Telerik team
 answered on 11 Jan 2010
5 answers
79 views

Good morning

I am developing an application WPF touchscreen, I need to have scrolling programatically.
The example 117850_117835 if it works to me, but with Q3 displays error in the following line.

Panel = Me.RadGridView1.ItemsControl.VirtualizingPanel

'temsControl' is not a member of 'Telerik.Windows.Controls.RadGridView'
As it works in the Q3

Thanks

Vlad
Telerik team
 answered on 11 Jan 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?