Adding custom page at end

Community plugins and extensions
Post Reply
User avatar
kevinvdheuvel
Posts: 91
Joined: Mon Mar 09, 2015 3:31 pm

Adding custom page at end

Post by kevinvdheuvel » Mon Dec 31, 2018 8:22 am

Hi

We would like to add the last page to our export file where we would like to display some use full information to the customer.

we tried to add that HTML content to footer but due to some space issue, the content will be splitting into two page.

we want a dedicated last page to provide some useful information to our customer
like :
printlastpage.PNG
printlastpage.PNG (9.84 KiB) Viewed 869 times
Do we have any options?

User avatar
Maxim Gorkovsky
Core Developer
Core Developer
Posts: 3060
Joined: Wed Jan 08, 2014 11:46 am

Re: Adding custom page at end

Post by Maxim Gorkovsky » Mon Dec 31, 2018 10:04 am

Hello.
There is a protected method you can override: Sch.plugin.AbstractExporter#onPagesExtracted. Try smth like this:

Code: Select all

Ext.define(null, {
  override: 'Sch.plugin.AbstractExporter',
  onPagesExtracted: function (pages) {
    pages.push({
      html: 'you html goes here',
      number: ++me.numberOfPages
    });
    this.callParent(arguments);
  }
})

User avatar
kevinvdheuvel
Posts: 91
Joined: Mon Mar 09, 2015 3:31 pm

Re: Adding custom page at end

Post by kevinvdheuvel » Mon Dec 31, 2018 12:04 pm

Hi

How can we register this new custom exporter to print plugin?
From API, we found this method registerExporter , but when/how do we call that method?

User avatar
Maxim Gorkovsky
Core Developer
Core Developer
Posts: 3060
Joined: Wed Jan 08, 2014 11:46 am

Re: Adding custom page at end

Post by Maxim Gorkovsky » Mon Dec 31, 2018 12:13 pm

This particular code snippet is an override, if you load it before instantiating scheduler you will get it working.
Assuming you want to use a proper way, you need to register exporter indeed. You can specify exportes in plugin config:

Code: Select all

Ext.define('MyExporter', {
  extend: 'Sch.plugin.exporter.MultiPage' // do not use abstract exporter here, it is too abstract
  onPagesExtracted: function () {...}
});
  
new Sch.panel.SchedulerGrid({
  plugins: [{
    ptype: 'scheduler_export',
    exporters: ['MyExporter'] // don't forget to require class properly
  }]
})
This should do the trick.

User avatar
Maxim Gorkovsky
Core Developer
Core Developer
Posts: 3060
Joined: Wed Jan 08, 2014 11:46 am

Re: Adding custom page at end

Post by Maxim Gorkovsky » Mon Dec 31, 2018 12:17 pm

Speaking of method you mentioned, registerExporter, it can be called in any point of time after plugin was instantiated and before you start export (or export dialog is shown). But providing config should be simplier

Post Reply