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. Image for the cookie policy date

Print Row Auto Height

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

3 Replies

JS Jayapradha S Syncfusion Team February 19, 2016 12:33 PM UTC

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





YA yapwen February 23, 2016 02:36 AM UTC

Dear jaya,

Thank you very much.

Regards,
Yap


SP Sowndaiyan Paulpandi Syncfusion Team February 23, 2016 01:09 PM UTC

Hi Yapwen, 

Thanks for the update.

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

Loader.
Up arrow icon