Hi,
There is a XamDataGrid with superheaders in the my application. When i tried to copy data from it, i got the message "The selection must be rectangular..." Is there a way to copy data from table like it:
Is this not fixed yet? I have the same problem with 13.2
Hello Nikolay,
Here is the support ticket number: CAS-70607-7FTRCS we have created on your behalf. I am going to link it to development issue: 84612, which Andrew created, so that you get automatically updated when a Feature Release containing the fix is available for download. You can get the new version from our website’s “My IG”, “My Keys & Downloads” tags: https://ko.infragistics.com/Membership/Default.aspx?panel=Downloads#Downloads
You can also monitor the support ticket’s progress through the “My Support Activity” tag: https://ko.infragistics.com/Membership/MySupport.aspx
You're right. It looks like the cells from the "Superheader" field are being selected as part of the range selection. I'll submit an issue for this. In the interim you could probably handle the ExecutingCommand event and remove/unselect any cells from that field. e.g.
void grid_ExecutingCommand(object sender, Infragistics.Windows.Controls.Events.ExecutingCommandEventArgs e) { if (e.Command == DataPresenterCommands.Cut || e.Command == DataPresenterCommands.Copy || e.Command == DataPresenterCommands.Paste) { FixCellSelection(sender as DataPresenterBase); } } private static void FixCellSelection(DataPresenterBase dp) { var selectedCells = dp.SelectedItems.Cells; if (selectedCells.Count == 0) return; HashSet<Field> fieldsToRemove = new HashSet<Field>(); foreach (var field in selectedCells[0].Field.Owner.Fields) { if (field.CellContentAlignmentResolved == CellContentAlignment.LabelOnly) fieldsToRemove.Add(field); } for (int i = selectedCells.Count - 1; i >= 0; i--) { if (fieldsToRemove.Contains(selectedCells[i].Field)) selectedCells[i].IsSelected = false; } }
private static void FixCellSelection(DataPresenterBase dp) { var selectedCells = dp.SelectedItems.Cells; if (selectedCells.Count == 0) return;
HashSet<Field> fieldsToRemove = new HashSet<Field>();
foreach (var field in selectedCells[0].Field.Owner.Fields) { if (field.CellContentAlignmentResolved == CellContentAlignment.LabelOnly) fieldsToRemove.Add(field); }
for (int i = selectedCells.Count - 1; i >= 0; i--) { if (fieldsToRemove.Contains(selectedCells[i].Field)) selectedCells[i].IsSelected = false; } }
I created the simply test solution and got the same result. Without a superheader it works fine. There are empty collapsed cells into the grid. I saw it with "Snoop". My test solution is below
<igDP:XamDataGrid x:Name="xGrid">
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings
AutoGenerateFields="False"
AllowClipboardOperations="Copy"
CopyFieldLabelsToClipboard="False"
AutoArrangeCells="Never" />
</igDP:XamDataGrid.FieldLayoutSettings>
</igDP:XamDataGrid>
public MainWindow()
{
InitializeComponent();
DataTable table = new DataTable();
table.Columns.Add("Column1", typeof(string));
table.Columns.Add("Column2", typeof(string));
table.Rows.Add(new object[] { 100, 1000 });
FieldSettings fs = new FieldSettings() { CellClickAction = CellClickAction.SelectCell };
FieldLayout layout = new FieldLayout();
Field field = new Field("Column1", "Column1") { Row = 1, Column = 0, Settings = fs };
layout.Fields.Add(field);
field = new Field("Column2", "Column2") { Row = 1, Column = 1, Settings = fs };
field = new UnboundField()
Column = 0,
Row = 0,
ColumnSpan = 2,
Label = "Superheader",
Settings = new FieldSettings() { CellContentAlignment = CellContentAlignment.LabelOnly }
};
xGrid.FieldLayouts.Add(layout);
xGrid.DataSource = table.DefaultView;
}
I'm not sure what the superheaders have to do with it. Basically that error message means that you have cells selected but you don't have the same fields selected in every row.