Hi Stefan,
We are using XamGrid and have made a column IsGroupBy=True to apply grouping by default and it is working fine except one thing that we want to make all rows expanded. We are using MVVM so can you help us in this regard. I use the XamGrid's Laoded and my code is
public static void ExpandAllGroups(XamGrid grid) { if (grid != null) { foreach (Row item in grid.Rows) { if (item.RowType == RowType.GroupByRow) { item.IsExpanded = true; } } } }
This is working fine Expand all groups at first time, but when i select the specific item from grid and edit it through dialogue box, on closed the dialogue box i get again all the record from database when assign to xamgrid collection who already bind it, collection are updated and also grid groups are collapsed and my selected row was unselect.
AddEditIndicators view = new AddEditIndicators(); AddEditIndicatorsViewModel vm = new AddEditIndicatorsViewModel(_selectedIndicator); vm.RequestViewClose += (sndr, evt) => { view.Close(); }; view.DataContext = vm; view.Closed += (s, a) => { this.InterpolatedIndicators = InterpolatedIndicatorFieldInfo.GetAll(false, false); }; view.Owner = ((App)App.Current).AppMainWindow; view.ShowDialog();
private List<InterpolatedIndicatorFieldInfo> _lstIndicators; public List<InterpolatedIndicatorFieldInfo> InterpolatedIndicators { get { return _lstIndicators; } set { _lstIndicators = value; OnPropertyChanged("InterpolatedIndicators"); } }
InterpolatedIndicators collection is bind with grid. AddEditIndicators is a view used for edit the record.
Hello Abu,
Thank you for your post. I have been looking into it and I suggest you create a Style for the GroupByRowCellsPanel and add an EventSetter for the Loaded event like this:
<Style TargetType="{x:Type igPrim:GroupByRowCellsPanel}"> <EventSetter Event="Loaded" Handler="GroupByRowCellsPanel_Loaded"/> </Style>
And also add the following handler:
private void GroupByRowCellsPanel_Loaded(object sender, RoutedEventArgs e) { ((sender as GroupByRowCellsPanel).Row as Row).IsExpanded = true; }
Please let me now if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Now groups are not collapsed but my selected row was unselect, and my cursor goes to top if i edit the last record of grid. how to fix the pointer on the selected row after closed the dialogue box.
Some thing more suppose i collapsed all groups after loaded, than i expand the one group and edit the record how to maintain the exact position after closed dialogue. Above code again expand all the groups , but i want only edited record group expand others are collapsed. how to resolve that issue.
Since I cannot be completely sure how your data is organized and how exactly do you edit your data through the dialog Window, I am not able to conclude what can cause your behavior, so could you please send me an isolated sample project and more details about the functionality you want to achieve, so I can investigate this further for you.
This is my main Grid expanded all rows
I select one row and make edit it through the following popup dialogue.
(AddEditIndicators Figure)
After save the record i fetch record again from database and assign to the grid collection.
public void SaveRecord() { if (_selectedIndicator == null) return; try { AddEditIndicators view = new AddEditIndicators(); AddEditIndicatorsViewModel vm = new AddEditIndicatorsViewModel(_selectedIndicator); vm.RequestViewClose += (sndr, evt) => { view.Close(); }; view.DataContext = vm; view.Closed += (s, a) => { this.InterpolatedIndicators = InterpolatedIndicatorFieldInfo.GetAll(false, false); }; view.Owner = ((App)App.Current).AppMainWindow; view.ShowDialog(); } catch (Exception exe) { System.Windows.MessageBox.Show(exe.Message); } }
public List<InterpolatedIndicatorFieldInfo> InterpolatedIndicators { get { return _lstIndicators; } set { _lstIndicators = value; OnPropertyChanged("InterpolatedIndicators"); } }
When i changed the collection than my focus out from selected row and goes to top and all groups are expanded again . Suppose first group i collapsed than after save record first is collapsed and second is opend and row was select how to resolve that issue.
I created a sample project for you where I save and load the state of the GroupByRows. Using my approach yo ucan save their state before you reload the data and load it after that.
Hope this helps you.