Hello,I would like to make an impression of the data of a XamDataGrid but only certain fields and my problem is that, when I launch the printing, all the fields of the DataSource are printed.I would like to be able to specify that only certain fields in particular should be printed, and without changing the visibility of the fields in the XamDataGrid.For example, I have 5 fields, Col1, Col2, Col3, Col4 and Col5 that appear in the XamDataGrid and I only want to print Col2 and Col3 and no others. How can I do?I can't find a solution, I tried:
private void BtnImprimer_Click(object sender, RoutedEventArgs e) { Report report = new Report(); EmbeddedVisualReportSection section = new EmbeddedVisualReportSection(dtg); section.PaginationStarting += new EventHandler<EmbeddedVisualPaginationEventArgs>(Section_PaginationStarting); report.Sections.Add(section); report.ReportSettings.PageOrientation = PageOrientation.Landscape; report.Print(); section.PaginationStarting -= Section_PaginationStarting; } private void Section_PaginationStarting(object sender, EmbeddedVisualPaginationEventArgs e) { DataPresenterBase presenter = e.VisualPaginator as DataPresenterBase; if (presenter != null) { presenter.FieldLayoutInitialized += Presenter_FieldLayoutInitialized; presenter.FieldLayoutInitializing += Presenter_FieldLayoutInitializing; } } private void Presenter_FieldLayoutInitializing(object sender, FieldLayoutInitializingEventArgs e) { e.FieldLayout.Fields.Clear(); e.FieldLayout.Settings.AutoGenerateFields = false; _GestionnaireConfigListe.InitialiserChampDatagridImpression(e.FieldLayout); }
But it no longer finds the fields to print.And with :
private void Presenter_FieldLayoutInitialized(object sender, FieldLayoutInitializedEventArgs e) { e.FieldLayout.Fields.Clear(); e.FieldLayout.Settings.AutoGenerateFields = false; _GestionnaireConfigListe.InitialiserChampDatagrid(e.FieldLayout); }
it prints empty pages to me.Is it possible to choose the fields that we want to print?
I use Infragistics 18.2
Hello,
After an investigation, I found this forum thread where a similar question has been discussed. According to this thread the printing engine prints a visual element. That means that it will print all visible fields of XamDataGrid.
A workaround I can suggest to create an additional grid where all required fields would be added and after that to print this grid.
If you require any further assistance on the matter, please let me know.
Sincerely,
Teodosia Hristodorova
Associate Software Developer
After further research, I determined that your approach could be applied if you the PaginationEnded event is handled as well.
I have created a small sample using PaginationStarting and PaginationEnded events. For the purposes of the example, I printed only the fields which indexes are odd numbers.
Attached you will find my sample for your reference. By modifying the FieldLayoutInitialized you will be able to achieve the desired behavior. Please test it on your side and let me know how it behaves.
Let me know if I may be of any further assistance.
5543.XamDataGrid_Print_Some_Fields.zip