Team,
I have a silverlight grid and enabled the GroupBy feature. One of the column in the grid is a textbox field which allows user to modify the value. There is a save button from the page for user to save the changes.
However, when user does the column groupby, expand one of the grouped row, then make some changes to the value and click on the save button. After the button clicked, the expanded group row is now collapsed. Is there a way we can keep the expanded row expand after the button click event?
Thanks for any advice.
Chris
Infragistics team,
Any help please?
Is there any help can be provided by Infragistic team? Haven't had any response from anyone from the team. Please help.
Hi Stefan,
I can provide you the code snippet. Sorry not able to provide you the sample project as it is quite big. Hope this help.
mycodepage.xaml
<ig:XamGrid x:Name="SearchResults" Grid.Row="2" AutoGenerateColumns="False" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ItemsSource="{Binding ResultSet}" RowHover="None" Foreground="Black" FontSize="8" TabNavigation="Once">
<ig:XamGrid.Resources>
</ig:XamGrid.Resources>
<ig:XamGrid.AddNewRowSettings>
<ig:AddNewRowSettings AllowAddNewRow="None" />
</ig:XamGrid.AddNewRowSettings>
<ig:XamGrid.ColumnChooserSettings>
<ig:ColumnChooserSettings AllowHiddenColumnIndicator="False" ColumnChooserDisplayText="Choose Columns..." AllowHideColumnIcon="True" HiddenColumnIndicatorToolTipText="Show Hidden Column(s)" />
</ig:XamGrid.ColumnChooserSettings>
<ig:XamGrid.ClipboardSettings>
<ig:ClipboardSettings AllowCopy="True" AllowPaste="False" CopyOptions="ExcludeHeaders" CopyType="SelectedCells" />
</ig:XamGrid.ClipboardSettings>
<ig:XamGrid.ColumnMovingSettings>
<ig:ColumnMovingSettings AllowColumnMoving="Indicator" />
</ig:XamGrid.ColumnMovingSettings>
<ig:XamGrid.ColumnResizingSettings>
<ig:ColumnResizingSettings AllowColumnResizing="Indicator" />
</ig:XamGrid.ColumnResizingSettings>
<ig:XamGrid.FilteringSettings>
<ig:FilteringSettings AllowFiltering="FilterRowTop" IsEnterKeyEditingEnabled="True" IsF2EditingEnabled="True" IsMouseActionEditingEnabled="SingleClick" IsOnCellActiveEditingEnabled="True" />
</ig:XamGrid.FilteringSettings>
<ig:XamGrid.GroupBySettings>
<ig:GroupBySettings AllowGroupByArea="Top" IsGroupByAreaExpanded="True" />
</ig:XamGrid.GroupBySettings>
<ig:XamGrid.SortingSettings>
<ig:SortingSettings AllowMultipleColumnSorting="True" AllowSorting="True" FirstSortDirection="Ascending" MultiSortingKey="Control" ShowSortIndicator="True" />
</ig:XamGrid.SortingSettings>
<ig:XamGrid.SelectionSettings>
<ig:SelectionSettings CellClickAction="SelectRow" CellSelection="None" ColumnSelection="None" RowSelection="Single" />
</ig:XamGrid.SelectionSettings>
<ig:XamGrid.SummaryRowSettings>
<ig:SummaryRowSettings AllowSummaryRow="Bottom" SummaryExecution="PriorToFilteringAndPaging" SummaryScope="ColumnLayout" />
</ig:XamGrid.SummaryRowSettings>
<ig:XamGrid.EditingSettings>
<ig:EditingSettings AllowEditing="Row" IsEnterKeyEditingEnabled="True" IsF2EditingEnabled="True" IsMouseActionEditingEnabled="DoubleClick" IsOnCellActiveEditingEnabled="True" />
</ig:XamGrid.EditingSettings>
<ig:XamGrid.Columns>
<ig:TemplateColumn Key="TradeDate" HeaderText="Trade Date" IsSummable="False" MinimumWidth="80" IsHideable="False">
<ig:TemplateColumn.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding TradeDate, StringFormat=MM/dd/yyyy}" />
</DataTemplate>
</ig:TemplateColumn.ItemTemplate>
<ig:TemplateColumn.FilterItemTemplate>
<TextBlock Text="{Binding Value}" ToolTipService.Placement="Mouse" ToolTipService.ToolTip="{Binding Value}" />
</ig:TemplateColumn.FilterItemTemplate>
<ig:TemplateColumn.FilterEditorTemplate>
<TextBox Text="{Binding Value, Mode=TwoWay}" Utilities:TextBoxRealtimeBindingUpdater.UpdateSourceOnChange="True" />
</ig:TemplateColumn.FilterEditorTemplate>
<ig:TemplateColumn.FilterColumnSettings>
<ig:FilterColumnSettings>
<ig:FilterColumnSettings.RowFilterOperands>
<ig:EqualsOperand />
<ig:GreaterThanOperand />
<ig:GreaterThanOrEqualOperand />
<ig:LessThanOperand />
<ig:LessThanOrEqualOperand />
<ig:NotEqualsOperand />
</ig:FilterColumnSettings.RowFilterOperands>
<ig:FilterColumnSettings.FilteringOperand>
</ig:FilterColumnSettings.FilteringOperand>
</ig:FilterColumnSettings>
</ig:TemplateColumn.FilterColumnSettings>
<ig:TemplateColumn.GroupByItemTemplate>
<TextBlock Text="{Binding Value, StringFormat=MM/dd/yyyy}" />
</ig:TemplateColumn.GroupByItemTemplate>
</ig:TemplateColumn>
<ig:TemplateColumn Key="FourCharCode" HeaderText="Trading Area" IsSummable="False" MinimumWidth="80" IsHideable="False" IsSortable="True">
<TextBlock Text="{Binding FourCharCode}" />
<ig:FilterColumnSettings >
<ig:ContainsOperand />
<ig:DoesNotContainOperand />
<ig:StartsWithOperand />
<ig:DoesNotStartWithOperand />
<ig:EndsWithOperand />
<ig:DoesNotEndWithOperand />
<ig:TemplateColumn Key="Quantity" HeaderText="Quantity" IsSummable="False" MinimumWidth="80" IsGroupable="False" IsHideable="False" IsSortable="True" HorizontalContentAlignment="Right">
<TextBlock Text="{Binding Quantity, Converter={StaticResource DoubleFormatConverter}}" />
<ig:TemplateColumn Key="IdeaTime" HeaderText="Target Time" IsSummable="False" MinimumWidth="80" MaximumWidth="320" Width="Auto" IsSortable="False" IsGroupable="False" IsHideable="False">
<StackPanel x:Name="IdeaTimeInput" Orientation="Horizontal" Margin="3,5,3,5" DataContext="{Binding}" >
<ig:XamNumericEditor x:Name="IdeaHour" Width="30" Margin="0,0,5,0" Mask="{}{double:-2.0}" Value="{Binding IdeaHour, Mode=TwoWay, UpdateSourceTrigger=Explicit, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Tag="IdeaHour" />
<ig:XamNumericEditor x:Name="IdeaMinute" Width="30" Margin="0,0,5,0" Mask="{}{double:-2.0}" Value="{Binding IdeaMinute, Mode=TwoWay, UpdateSourceTrigger=Explicit, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Tag="IdeaMinute" />
<ig:XamNumericEditor x:Name="IdeaSecond" Width="30" Margin="0,0,5,0" Mask="{}{double:-2.0}" Value="{Binding IdeaSecond, Mode=TwoWay, UpdateSourceTrigger=Explicit, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Tag="IdeaSecond" />
</StackPanel>
</ig:XamGrid.Columns>
</ig:XamGrid>
<Grid Grid.Row="1" Grid.Column="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button x:Name="SaveChanges" Grid.Column="0" HorizontalAlignment="Right" Style="{StaticResource GreenButton}" Content="Save" MinWidth="120" Click="SaveChanges_Click" />
</Grid>
mycodepage.xaml.cs
private void SaveChanges_Click(object sender, RoutedEventArgs e)
{
// Given grid rows are "Group By" on FourCharCode column and one of the grouped row is expanded
// performing the update from getting the value in the IdeaHour, IdeaMinute, and IdeaSecond and save to the database
// some update code goes here
// rebind the record to the XamGrid
// rebind code goes here
// After the rebind, the expanded row is now collapsed.
// How do we make the expanded row to be kept expanded after the update????
}
Hello,
Could you please be more specific what is the code you use here:
Do you mean that you rebind the whole ItemsSource of the XamGrid, because if you do so, it is expected that the Rows are collapsed and the thing you could do is iterating them before saving and save their Expand state in an array for example and after that iterate them again and set their expand state.
Looking forward for your reply.
Yes, rebind the whole ItemsSource of the XamGrid. Mind to tell me while I have it iterating, how can I retrieve the information of the Expand state? It would be great if you have some code snippet on how to do that. Greatly appreciated it!
You can iterate XamGrid’s Rows and create the array with the IsExpanded states like this:
bool[] isExpandedArray = new bool[xamGrid1.Rows.Count]; for (int i = 0; i < xamGrid1.Rows.Count; i++) { if (xamGrid1.Rows[i].IsExpanded) { isExpandedArray[i] = true; } else { isExpandedArray[i] = false; } }
Hope this helps you.
thanks, it works!
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.