2X faster development
The ultimate WPF UI toolkit to boost your development speed.
All the groups will be printed in expanded state by default in WPF DataGrid (SfDataGrid). You can also avoid this and maintain the expanded states of group as in view when printing by inheriting the GridPrintManager and overriding the GetSourceListForPrinting method.
Refer to the following code sample for assigning source list for printing.
dataGrid.PrintSettings.PrintManagerBase = new CustomPrintManagerBase(dataGrid); dataGrid.ShowPrintPreview(); public class CustomPrintManagerBase : GridPrintManager { public CustomPrintManagerBase(SfDataGrid dataGrid) : base(dataGrid) { } protected override IList GetSourceListForPrinting() { if (View.GroupDescriptions.Any()) { var records = ToIEnumerable(View.TopLevelGroup.GetEnumerator()).ToList(); List<NodeEntry> expandedGroups = new List<NodeEntry>(); foreach(var record in records) { if(record is RecordEntry) { var group = record.Parent as Group; if (group != null && group.IsExpanded) expandedGroups.Add(record); } else if(record is Group) { var group = record as Group; if(group.IsTopLevelGroup || group.Level == 1) { expandedGroups.Add(group); } //For Multi-ColumnGrouping else { var parentGroup = group.Parent as Group; if (parentGroup != null && parentGroup.IsExpanded) expandedGroups.Add(group); } } } return expandedGroups; } return base.GetSourceListForPrinting(); } }
|
2X faster development
The ultimate WPF UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.