I've been working on implementing multiple record selection in a XamDataGrid without using the Record Selector, but rather simply by using the standard behaviors of shift-click and ctrl-click. I found that by setting SelectionTypeCell=null, SelectionTypeRecord=Extended, and setting the CellClickAction of all fields to SelectRecord, this would work.
Unfortunately, I now need to do the same thing on a XamDataGrid where every record field is editable in one way or another. This precludes using CellClickAction=SelectRecord. Does anyone know of an integrated way to allow multiple selection on such a grid?
Ideally users would be able to:
-Single click in a cell to activate the relevant record and set the cell to editmode = true.
-Activate one record with a regular single click, then shift click another row and have all rows between the first and second (inclusive) set to selected.
-Ctrl-click any record to add it to the selected items.
Thoughts?
Hello,
I apologize that this post was not answered sooner. We are making the effort to ensure all posts are addressed by an Infragistics expert.
2. and 3. are the default behaviors of the XamDataGrid. As per your first requirement, you can select the record when the cell is entering edit mode. You can use the EditModeStarting event and set the e.Cell.Record.IsSelected property to true.
Thank you!
Hi,
I have the same requirements.
@Alex: I tried your approach, but if I do this, I can only select one item at a time. If I select more than one, in the SelectionChangedEvent there are all Items I have selected, but on screen I can only see the one clicked on (or if using shift and arrow keys, the selected one is the last one clicked on).
I have the following properties set:
<XamDataGrid x:Name="MultiTest"EditModeStarting="SomeHandler">
<XamDataGrid.FieldLayoutSettings><FieldLayoutSettingsRecordSelectorLocation="None"SelectionTypeRecord="ExtendedAutoDrag"SelectionTypeCell="ExtendedAutoDrag"SelectionTypeField="SingleAutoDrag"/></XamDataGrid:FieldLayoutSettings>
<XamDataGrid:FieldSettings><FieldSettingsLabelClickAction="Nothing"AllowEdit="True"CellClickAction="Default"/></XamDataGrid:FieldSettings>
Code Behind:
private void SomeHandler(object sender, EditModeStartingEventArgs e){ var record = e.Cell.Record; record.IsSelected = true;}
somewhere in code I add a SelectionChangedHandler:xamDataGrid.SelectedItemsChanged += OnSelectionChanged;
In the Handler I see that the items I have selected seem to be in the SelectedItems ... but only one Item is highlighted in the grid.
Any suggestions?
Huh, I tried it again and now the selected items is always only one...
Ok, now I got it ... Had to set SelectionTypeCell to "None" (and removed the CellClickAction="Default").