You need to sign in to do that
Don't have an account?
krios demo
Display the selected rich text image on popup
I have a scenario.
I have products properties in which all product details stored which are retrived from apex class.
In the object I have Product_Image__c named rich text field is there in which my all individual product images are stored.
In my LWC Component when i clicked on "View Image" button same related image should be open on popup.
HTML:
<lightning-button variant="success" label="View Product Image" class="slds-var-m-left_x-small"
title="View Product Details" value={product.Id} onclick={showmodal}></lightning-button>
<template if:true={isShowModal}>
<div class="slds-modal__container">
<header class="slds-modal__header">
<!-- sldsValidatorIgnoreNextLine -->
<lightning-button-icon icon-name="utility:close" alternative-text="Close this window" size="large"
variant="bare-inverse" onclick={CloseModal} class="slds-modal__close">
</lightning-button-icon>
</header>
<div class="slds-modal__content slds-var-p-around_medium" id="modal-content-id">
<lightning-formatted-rich-text value={selectedproductimage.product.Product_Images__c} onclick={openModal}>
</lightning-formatted-rich-text>
</div>
</div>
</template>
JS:
export default class VIP_ProductCatalogue extends NavigationMixin (LightningElement) {
@track Products;
@track productsFound;
@track isModalOpen = false;
@track isShowModal = false;
selectedproductimage;
showmodal()
{
this.selectedproductimage = this.currentTarget.template.item;
this.isShowModal = true;
}
CloseModal()
{
this.isShowModal = false;
}
Below image is for ref of my UI
I have products properties in which all product details stored which are retrived from apex class.
In the object I have Product_Image__c named rich text field is there in which my all individual product images are stored.
In my LWC Component when i clicked on "View Image" button same related image should be open on popup.
HTML:
<lightning-button variant="success" label="View Product Image" class="slds-var-m-left_x-small"
title="View Product Details" value={product.Id} onclick={showmodal}></lightning-button>
<template if:true={isShowModal}>
<div class="slds-modal__container">
<header class="slds-modal__header">
<!-- sldsValidatorIgnoreNextLine -->
<lightning-button-icon icon-name="utility:close" alternative-text="Close this window" size="large"
variant="bare-inverse" onclick={CloseModal} class="slds-modal__close">
</lightning-button-icon>
</header>
<div class="slds-modal__content slds-var-p-around_medium" id="modal-content-id">
<lightning-formatted-rich-text value={selectedproductimage.product.Product_Images__c} onclick={openModal}>
</lightning-formatted-rich-text>
</div>
</div>
</template>
JS:
export default class VIP_ProductCatalogue extends NavigationMixin (LightningElement) {
@track Products;
@track productsFound;
@track isModalOpen = false;
@track isShowModal = false;
selectedproductimage;
showmodal()
{
this.selectedproductimage = this.currentTarget.template.item;
this.isShowModal = true;
}
CloseModal()
{
this.isShowModal = false;
}
Below image is for ref of my UI
Shri Raj