How to print row summary and group summary in SfDatagrid

Hi dears,

I use SfDatagrid in my application and when I printing SfDatagrid, its going to print data.

I need to print data and row summary and group summary.


9 Replies

MA Mohanram Anbukkarasu Syncfusion Team April 8, 2022 01:24 PM UTC

Hi Hossein,


In SfDataGrid, the summary rows will be printed by default when printing the entire SfDataGrid. We have prepared a sample for this. Please have a look at the attached sample and let us know if you require further assistance.


Regards,

Mohanram A.


Attachment: SfDataGrid_Demo_a9ce1792.zip


HT Hossein Tavakoli April 11, 2022 12:30 PM UTC

The summary rows will be printed by default when printing the entire SfDataGrid but Group Summary will not printed.

Also when we use SfDataPager and wants to print one page of SfDataGrid rows summary and group summary will not printed.


my code :


        public void PrintDataGrid(object parameter)

        {

            try

            {

                var DataGrid = parameter as SfDataGrid;

                DataGrid.PrintSettings = new Syncfusion.UI.Xaml.Grid.PrintSettings();

                DataGrid.PrintSettings.PrintManagerBase = new CustomPrintManager(DataGrid);

                DataGrid.PrintSettings.AllowRepeatHeaders = true;

                DataGrid.ShowPrintPreview();

            }

            catch { }

        }

    }


    public class CustomPrintManager : GridPrintManager

    {

        public CustomPrintManager(SfDataGrid grid) : base(grid) { }

        protected override IList GetSourceListForPrinting()

        {

            return View.Records.ToList();

        }

    }



DM Dhanasekar Mohanraj Syncfusion Team April 12, 2022 02:30 PM UTC

Hi Hossein,

The reported problem occurs due to returning the View.Records.ToList() in customization of PrintManager. As we mentioned earlier In SfDataGrid, the summary rows will be printed by default when printing the entire SfDataGrid. Please revert to us with the below mentioned details.

  1. Details about the purpose of customizing PrintManager.

  2. Complete code snippet related to SfDataGrid (Xaml & Code behind)

It will be more helpful for us to find the exact cause for the issue and to provide a prompt solution.

Regards,
Dhanasekar M.



HT Hossein Tavakoli April 14, 2022 01:34 PM UTC

I use a SfDataGrid (Group by 'Name' , Group summary , Rows summary ) with a SfDataPager exactly like this picture:

Untitled.jpg


I want to print SfDataGrid with group summary and rows summary like bellow picture. Also when I print SfDataGrid just print current page (active page in SfDataPager) not all rows. Just current page with group summary and rows summary.

Untitled.jpg

this is my purpose print result.



DM Dhanasekar Mohanraj Syncfusion Team April 15, 2022 01:08 PM UTC

Hi Hossein,


Currently, we are checking the feasibilities to achieve your requirement. We will check and update you further details on April 19, 2022.


Regards,

Dhanasekar M



DM Dhanasekar Mohanraj Syncfusion Team April 19, 2022 01:56 PM UTC

Hi Hossein,



Still, we are checking on this. We will check and update you further details on April 21. 2022.

We appreciate your patience and understanding.


Regards,
Dhanasekar M.



DM Dhanasekar Mohanraj Syncfusion Team April 21, 2022 02:01 PM UTC

Hi Hossein,

We have checked the feasibilities to achieve your requirement “Print the active page with the summaries” in our end. We also regret to inform you that​​​, our SfDatagrid source architecture does not provide support to achieve your requirement.

Regards,
Dhanasekar M.



HT Hossein Tavakoli April 22, 2022 08:20 AM UTC

Thanks for your responsibility.

It's not possible to print " Print the active page with the summaries" or SfDataGrid does not support print "Group summary"?

Can I print group summary and row summary without SfDataPager (print all rows binding to SfDataGrid with rows summary and group summary)?



DM Dhanasekar Mohanraj Syncfusion Team April 25, 2022 02:01 PM UTC

Hi Hossein,

You can print the group summaries by two ways like below,

Case 1 :

If you print all group summaries you need to expand all groups before printing with the help of AutoExpandGroups property shown in below example,

Xaml :

<syncfusion:SfDataGrid Name="dataGrid"

                        AllowFiltering="True"

                        AutoExpandGroups="True"

                        ShowGroupDropArea="True"

                        ColumnSizer="Auto"

                        ItemsSource="{Binding OrdersListDetails}" />


C#:

dataGrid.ShowPrintPreview();



Case 2:

You can print entire grid with its summaries using below code,

C#:

PdfViewerControl pdfviewer = new PdfViewerControl();

MemoryStream pdfstream = new MemoryStream();

var document = dataGrid.ExportToPdf();

document.Save(pdfstream);

pdfviewer.Load(pdfstream);

dataGrid.ShowPrintPreview();


We have modified the sample based on your scenarios. Please check the sample and revert us if you need further assi
stance for this.

Regards,
Dhanasekar M.


Attachment: SfDataGrid_Demo_1c46d910.zip

Loader.
Up arrow icon