I am trying to get the selected rows in a datagrid.
I dont want the user to have to use the row/record selector, so have enabled row selection on any cell.
And i want the user to be able to select multiple rows using ctrl/shift + click.
<igDataPresenter:XamDataGrid x:Name="dataGrid" DockPanel.Dock="Top" >
<igDataPresenter:FieldSettings AllowEdit="False" CellClickAction="SelectRecord" />
<igDataPresenter:XamDataGrid.FieldLayoutSettings>
<igDataPresenter:FieldLayoutSettings
AutoFitMode="Always"
AutoGenerateFields="False"/>
</igDataPresenter:XamDataGrid.FieldLayoutSettings>
<igDataPresenter:XamDataGrid.FieldLayouts>
<igDataPresenter:FieldLayout>
<igDataPresenter:FieldLayout.Fields>
<igDataPresenter:Field Name="MessageNumber" Label="Message Number" />
i would like to be able to see the selected records (list/collection) in the code behind (when selection changes)
in my DataGrid_CellActivated and DataGridSelectedItemsChanged methods i *should* be able to do "DataGrid.SelectedItems" and see the records that have been selected.
However this is not working.
e.g.
I click a cell, the cell activated event fires and
e.Cell.Record.IsSelected = false
and
e.Cell.IsSelected = false
DataGridSelectedItemsChanged is not fired and (bearing in mind that AllowEdit="False") the cell is put into edit mode.
if i ctrl + click another cell
cell activated fires (same results as above) then DataGridSelectedItemsChanged is fired.
but,
DataPresenter.SelectedItems has one record not two.
The main thing i would like to know is, how should i determine the selected records?
thanks.
Hello Aparna,
I can suggest you see this forum thread:
http://forums.infragistics.com/forums/p/62516/316776.aspx
where a similar issue is discussed.
Thanks for reply,
Can you please provide some sample for the below query.
How to handle XamGrid Row Selection (Single/Mutlipule) in MVVM pattren?
Regards,
Aparna
Thank you for your post. I have been looking into it but I cannot be completely sure how did you bound the XamDataGrid to the ListBox, so could you please send me an isolated sample project, where this is reproduced, so I can investigate it further for you.
Looking forward for your reply.
Hello,
I am facing the similar issue...
How to Get the Colum Header when the XamGrid is binded with ListBox Items?
I am binding XamDataGrid with ListBoxItem but not able to get the Colum header as expected.Some how I am getting the ListBoxItems in the row with default Colum Header as "Value".
I am Binding the ListBox Item in XAML as below :
<
ig:XamDataGrid x:Name="igGrid" Grid.Row="0" Height="400" SelectedItemsChanged="IgGrid_SelectedItemsChanged" DataSource="{Binding Path
=SimulationList}">
<ig:XamDataGrid.FieldLayoutSettings
>
<ig:FieldLayoutSettings AutoGenerateFields="True"
SelectionTypeCell="Default"
SelectionTypeField="Single"
SelectionTypeRecord
="Extended"
/>
</ig:XamDataGrid.FieldLayoutSettings
<ig:XamDataGrid.FieldLayouts
<ig:FieldLayout IsDefault
="True" >
<ig:Field Name="Name" Label="Sim Name" Visibility="Visible"> </ig:Field
</ig:FieldLayout
</ig:XamDataGrid.FieldLayouts
<ig:XamDataGrid.FieldSettings
<ig:FieldSettings LabelClickAction
="SelectField" />
</ig:XamDataGrid.FieldSettings
</ig:XamDataGrid
<!-- XamDataGrid -->
SimulationList is a ListBox Item
Yes, It is controlled by the DataRecordCellArea element and its brush properties, like :
BackgroundActive, BorderActiveBrush, etc. The same is for the selection. You can create a style for the DRCA and change these brushes so that active and selected records can be easily distinguished.