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
  • 340
    Verified Answer
    Offline posted

    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

Reply Children