This is a migrated thread and some comments may be shown as answers.

Print Chartview and PivotGrid together

3 Answers 60 Views
PivotGrid and PivotFieldList
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 07 Jun 2015, 10:16 PM

Hello,

 is there a possibility to print the chartview and the Pivotgrid together in one 

Printdocument? 

 

regards

Thomas

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 08 Jun 2015, 02:00 PM
Hi Thomas,

Thank you for writing. 

This is possible and to achieve it you should create a custom class that implements IPrintable. For example:
class MyPrinter : IPrintable
{
    public IPrintable Chart { get; set; }
 
    public IPrintable Pivot { get; set; }
 
    private int pages;
 
    public int BeginPrint(RadPrintDocument sender, System.Drawing.Printing.PrintEventArgs args)
    {
        this.pages = Chart.BeginPrint(sender, args) + Pivot.BeginPrint(sender, args);
 
        return pages;
    }
 
    public bool EndPrint(RadPrintDocument sender, System.Drawing.Printing.PrintEventArgs args)
    {
        return false;
    }
 
    public bool PrintPage(int pageNumber, RadPrintDocument sender, System.Drawing.Printing.PrintPageEventArgs args)
    {
        if (pageNumber < pages)
        {
            this.Pivot.PrintPage(pageNumber, sender, args);
 
            return true;
        }
 
        this.Chart.PrintPage(1, sender, args);
        return false;
    }
 
    public Form GetSettingsDialog(RadPrintDocument document)
    {
        return null;
    }

Then you can use the above class to create new PrintDocument:
RadPrintDocument doc = new RadPrintDocument();
 
doc.AssociatedObject = new MyPrinter()
{
    Chart = chart1,
    Pivot = radPivotGrid1
};
 
RadPrintPreviewDialog dialog = new RadPrintPreviewDialog();
dialog.Document = doc;
dialog.ShowDialog();

Please let me know if there is something else I can help you with.

Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Thomas
Top achievements
Rank 1
answered on 08 Jun 2015, 07:38 PM

Hello Dimitar,

thank you for your help. It was a fast and very helpful answer.
Some modifications had to be done in order to have a good solution.

1. Printersettings 
2. First Chartprint then Pivotprint
3. Pagenumber check (in case of landscape = false different number of pages)

    class MyPrinter : IPrintable
    {
        public IPrintable Chart { get; set; }
        public IPrintable Pivot { get; set; }
        private int pagesP;
        private int pagesC;
        private int pages;
        public int BeginPrint(RadPrintDocument sender, System.Drawing.Printing.PrintEventArgs args)
        {
            this.pagesC = Chart.BeginPrint(sender, args);
            this.pagesP = Pivot.BeginPrint(sender, args);
            this.pages = pagesC + pagesP;
            return pages;
        }
        public bool EndPrint(RadPrintDocument sender, System.Drawing.Printing.PrintEventArgs args)
        {
            return false;
        }
        public bool PrintPage(int pageNumber, RadPrintDocument sender, System.Drawing.Printing.PrintPageEventArgs args)
        {
            if (pageNumber <= pagesC)
            {
                this.Chart.PrintPage(pageNumber, sender, args);
                return pageNumber < pages;
            }
            this.Pivot.PrintPage(pageNumber-pagesC, sender, args);
            return pageNumber < pages;
        }
        public Form GetSettingsDialog(RadPrintDocument document)
        {
            return  Pivot.GetSettingsDialog(document);
       }
    }

best regards

Thomas

 

0
Dimitar
Telerik team
answered on 09 Jun 2015, 08:59 AM
Hello Thomas,

Thank you for sharing your solution with the community. Do not hesitate to contact us if you have other questions.
 
Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
PivotGrid and PivotFieldList
Asked by
Thomas
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or