Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
290
XamDataGrid print specific field
posted

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

Parents Reply Children