I have a small problem with copy xamPivotGrid data by using Ctrl + C.
To Copy all data from xamPivotgrid I'm using a KeyDown event on xamPivotGrid.
pivotGrid.KeyDown += (s, e) => { if (e.Key == Key.C && (ModifierKeys.Control == Keyboard.Modifiers)) { if (pivotGrid.SelectionSettings.SelectedRows.Count > 0) { StringBuilder sb = new StringBuilder(); sb.AppendLine("\t" + String.Join("\t", pivotGrid.SelectionSettings.SelectedRows.FirstOrDefault().Cells.Select(cell => cell.DataColumn.HeaderText))); foreach (var Item in pivotGrid.SelectionSettings.SelectedRows) { sb.AppendFormat("{0}\t", Item.HeaderText.Replace("\r\n", " ")); sb.AppendFormat("{0}\n", String.Join("\t", Item.Cells.Select(a => { ICell Cell = (a.Data as ICell); return Cell == null ? String.Empty : (a.Data as ICell).FormattedValue; }))); } Clipboard.SetText(sb.ToString()); } } if (e.Key == Key.A && ModifierKeys.Control == Keyboard.Modifiers) { foreach (Infragistics.Controls.Grids.PivotDataRow Row in pivotGrid.DataRows) { pivotGrid.SelectionSettings.SelectedRows.Add(Row); } } };
The Problem is, I do not to Focus the Pivot Grid. If Pivot Grid is not focused, user cannot perform Mark + Copy. And the focus works only if I'm using TAB key. Usually a click on control element should be enough to set the focus. Is there any easy way to perform copy of table?
wbr
Roman
Hello Roman and thank you for posting!
I have been looking into your requirements and created a sample project based on the provided code snippets for cell selection and copying. It seems that the solution selects and copies the displayed values of the grid correct when the control is focused. If the control is not focused, the key events will be handled by the control (xamPivotGrid) that has the focus and the select and copy operation will not be performed for XamPivotGrid. Could you please have a look at the sample application and let me know if it meets your requirements or the requirements you need to meet are different? Please feel free to modify the project to illustrate the scenario on your side.
Hello,
I am just checking if you had a chance to look into this and if you would like any further assistance on the matter.
I've checked the demo code. The interesting thing is:
In my version still cannot copy selected rows from the Pivot Grid. Click into the top most hierarchy button do not set focus to pivot grid (v14.1).
BUT the demo code works fine. Click on the top most hierarchy make grid focused (v13.2).
Current used PivotGrid Configuration:
Grid.Row="1" Margin="10" Grid.Column="0" Grid.ColumnSpan="10" HorizontalAlignment="Stretch" ParentInFrontForRows="False" TotalColumnStyle="{StaticResource TotalColumnCellsStyle}" TotalRowStyle="{StaticResource TotalColumnCellsStyle}" CellStyle="{StaticResource PivotCellStyle}" DataSource="{Binding Path=FlatData}" VerticalAlignment="Top" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" AllowCompactLayout="True" x:Name="PivotGrid">
Events for PivotGrid:
PivotGrid_CellControlAttached
CellEdited
KeyDown
Hello Roman,
I am just checking if you have any further questions on this matter. Please do not hesitate to let me know if you do.
I have been looking into your issue. I have added the settings for the XamPivotGrid, that you have provided to the sample application, that Maria has provided. The I have tested the sample application with the latest service release for 14.1 - 2216 and the RTM version for 14.2. In both versions the selection works as expected - when the XamPivotGrid is on focus it selects and copies the rows.
In order to be able to further investigate this issue for you, would you please provide me with the exact version of our controls, that you are using (volume and service release)?
Also, if possible, would you please modify the provided sample application, with the functionality you are using, so the sample reproduces the issue?
Thank you for the cooperation. Looking forward to hearing from you.