We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Print Row Auto Height

Thread ID:

Created:

Updated:

Platform:

Replies:

122129 Feb 18,2016 10:05 AM Feb 23,2016 08:09 AM WPF 3
loading
Tags: SfDataGrid
yapwen
Asked On February 18, 2016 10:05 AM

Hello Sir,

How to set the row auto height when print from SfDataGrid ?

I manage to set the SfDataGrid row auto height but not for print preview and print.

Please see attached for more info .

Thank you.

Regards,
Yap 

Attachment: SfDataGrid_fa99aa74.zip

Jayapradha S [Syncfusion]
Replied On February 19, 2016 07:33 AM

Hi Yapwen, 

Thank you for contacting Syncfusion Support.

You can achieve your requirement by overriding the GridPrintManager Class and GetRowHeight method as shown below,


Code Example:

syncgrid.PrintSettings.PrintManagerBase = new CustomPrintManager(this.syncgrid);

public class CustomPrintManager : GridPrintManager

    {

        SfDataGrid dataGrid;

        GridRowSizingOptions gridRowSizingOptions = new GridRowSizingOptions();

        double Height = double.NaN;

        public CustomPrintManager(SfDataGrid grid)

            : base(grid)

        {

            dataGrid = grid;           

        }

      

        protected override double GetRowHeight(object record, int rowindex)

        {

            if(record != null)

            {

                var actualrowindex = GridIndexResolver.ResolveToRowIndex(this.dataGrid, rowindex);

                if (this.dataGrid.GridColumnSizer.GetAutoRowHeight(actualrowindex, gridRowSizingOptions, out Height))

                {

                    return Height;

                }

            }

            return base.GetRowHeight(record, rowindex);

        }


    }



In GetRowHeight method we have resolved rowindex using ResolveToRowIndex. Since GetRowHeight method receives the RecordIndex value. We will fix this issue in our upcoming release to pass rowindex, so you do not have to use ResolveToRowIndex.

Please find the sample from the following location,
Sample Link: http://www.syncfusion.com/downloads/support/forum/122129/ze/PrintingDemo-142227675

Please refer the below UG doc to customize the GridPrintManager,
UG Link: http://help.syncfusion.com/wpf/sfdatagrid/printing#printing-customization 

Regards,
Jayapradha




yapwen
Replied On February 22, 2016 09:36 PM

Dear jaya,

Thank you very much.

Regards,
Yap

Sowndaiyan Paulpandi [Syncfusion]
Replied On February 23, 2016 08:09 AM

Hi Yapwen, 

Thanks for the update.

Please let us know if you need further assistance.
Regards,
Sowndaiyan

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;