Hi All,
I am working with Infragistics V10.2. I am using Infragistics XamDataGrid where on grid Load I need to show the first row as selected by default and user should be able to select a row on pressing enter/return key.
User should be able to scroll down and press enter to select any record in the grid (no usage of Mouse in the application).
I don't know if there is any property that allows to do this in XAMDATAGARID.
Please advise.
Thanks in Advance.
..............
Rakesh
Hello Stephen,
Thank you for your post.
I have been looking into your requirements and the code snippet that you have provided. What I can suggest is to handle the InitializeRecord event of XamDataGrid instead of FieldLayoutInitialized. In the event handler you can set the IsActive property of the first row. I created a short sample application based on your scenario to show you how you can implement this approach. In the sample I handled the InitializeRecord event of XamDataGrid. In the even handler I used Dispatcer to delay the executing of the code and avoid some exception, because when InitializeRecord event is fired the CellValuePresenter aren’t created yet. Also in it I checked if e.Record.Index is equal to zero I set the IsActive property to true and unhandled the event of XamDataGrid. Please let me know if I missing something.
If you require any further assistance, please do not hesitate to ask.
Hi, I found this post when searching for a similar issue I'm having with version 14.2.
My requirement is that when the records are loaded into my grid, I want to select the first one so that it's highlighted. To achieve this I've added a handler to FieldLayoutInitialized, which simply calls the exact same code from the sample solution posted by Stefan. What I find is that the first row is never highlighted, however, if I change the code to set IsActive = true on any non zero indexed row then they are highlighted.
It appears there must be some internal log specific to the first row that causes the highlighting not to take affect. If it helps to reproduce then here's the code:
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" xmlns:igWPF="http://schemas.infragistics.com/xaml/wpf"> <Window.Resources> <Style x:Key="HighlightedSelectedRowStyle" TargetType="{x:Type igWPF:DataRecordCellArea}"> <Setter Property="BackgroundActive" Value="Orange" /> <Setter Property="BackgroundSelected" Value="Orange" /> </Style> </Window.Resources> <Grid> <igWPF:XamDataGrid RecordFilterChanged="xamDataGrid1_RecordFilterChanged" BindToSampleData="True" Name="xamDataGrid1" FieldLayoutInitialized="XamDataGrid1_OnFieldLayoutInitialized">
<igWPF:XamDataGrid.FieldLayoutSettings> <igWPF:FieldLayoutSettings AllowDelete="False" DataRecordCellAreaStyle="{StaticResource HighlightedSelectedRowStyle}" RecordSelectorLocation="None" SelectionTypeRecord="Single" /> </igWPF:XamDataGrid.FieldLayoutSettings> <igWPF:XamDataGrid.FieldSettings> <igWPF:FieldSettings AllowEdit="False" AllowRecordFiltering="True" LabelTextAlignment="Center" CellClickAction="SelectRecord" /> </igWPF:XamDataGrid.FieldSettings> </igWPF:XamDataGrid> </Grid></Window>
private void XamDataGrid1_OnFieldLayoutInitialized(object sender, FieldLayoutInitializedEventArgs e) { if (xamDataGrid1.RecordManager.GetFilteredInDataRecords().Count() != 0) { xamDataGrid1.RecordManager.GetFilteredInDataRecords().ToList()[1].IsActive = true; } }
Would love to hear back about a way to solve this.
Thanks,
Steve
Hello,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Looks really good to me. It's doing exactly what I need to. I'm still new to WPF: The UI options are mind boggling at times compared to WinForms. You folks have a really good product suite. Thanks for the help!!
You can set the XamDataGrid’s FieldSettings’ FilterEvaluationTrigger Property to OnEnterKeyOrLeaveCell. This way the filter will apply if you press enter or leave the FilterCell.