0

On Account record page i have a parent LWC which has a button. On click i am redirecting to childLWC.

ChildLWC has two layouts. On print the page i want the two layouts should come in two different pages. The issue is currently it is coming in one page while print preview.I tried using page break, but it is not working.

Can anyone please tell what can be the workaround..

ParentLWC HTML -

<template>
      <lightning-button label="Redirect" title="Back to record" onclick={redirect} ></lightning-button>
</template>

JS-

import { LightningElement } from 'lwc';
import { NavigationMixin } from "lightning/navigation";

export default class Parentcomponent extends NavigationMixin(LightningElement) {

    connectedCallback() {
        this.redirecttochild = {
          type: "standard__component",
          attributes: {
            componentName: "c__test"
          },
          state: {
            c__recordId: this.recordId
          }
        };
        this[NavigationMixin.GenerateUrl](this.redirecttochild ).then(
          url => (this.url = url)
        );
      }

    redirect(){
        this[NavigationMixin.Navigate](this.redirecttochild , false);
    }
}

Aura warpper -

<aura:component implements="lightning:isUrlAddressable,force:hasRecordId" access="global" >
    <c:childcomponent/>
</aura:component>

ScreenSHot

enter image description here

Child LWC -

HTML -

<template>
    <div>
        <lightning-layout>
          <lightning-layout-item>
            First Page
          </lightning-layout-item>
          </lightning-layout>
      </div>
      <div style="page-break-before: always;">
        <lightning-layout>
          <lightning-layout-item>
            Second Page
          </lightning-layout-item>
        </lightning-layout>
      </div>
</template>

ScreenShot -

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.