Add Popup in LWC
Add Popup in LWC
html
<template>
</div>
</div>
</div>
<template if:true={contacts.data}>
<lightning-datatable
key-field="Id"
data={contacts.data}
columns={columns1}
>
</lightning-datatable>
</template>
<div class="slds-m-around_medium">
<template if:true={Accounts.data}>
<lightning-datatable
key-field="Id"
data={Accounts.data}
columns={columns}
onrowaction={openModal}
>
</lightning-datatable>
</template>
</div>
</lightning-card>
<template if:true={isModalOpen}>
<div class="slds-modal__container">
<header class="slds-modal__header">
<lightning-icon icon-name="utility:close"
alternative-text="close"
variant="inverse"
size="small" ></lightning-icon>
<span class="slds-assistive-text">Close</span>
</button>
</header>
<template if:true={getAllAccounts.data}>
<lightning-datatable
key-field="Id"
data={getAllAccounts.data}
columns={columns1}
>
</lightning-datatable>
</template>
</div>
<p><b>Modals/Popup Box are used to display content in a layer above the app.
</b></p>
<p><b>This paradigm is used in cases such as the creation or editing of a record, as well
as various types of messaging and wizards.
</b></p>
</div>-->
<footer class="slds-modal__footer">
</footer>
</div>
</section>
</template>
</template>
*).js
const COLS = [
name: 'View',
title: 'View',
disabled: false,
value: 'View',
iconPosition: 'left'
}}
];
];
@track columns1=COLS1;
@track v_Offset=0;
@track v_TotalRecords;
@api accName;
@track currentAccountName;
@track searchAccountName;
@track recid;
@track results;
@track error;
//@api getAllAccounts;
handleChangeAccName(event){
this.currentAccountName = event.target.value;
handleAccountSearch(){
this.searchAccountName = this.currentAccountName;
openModal(event) {
//this.currentAccountName = event.target.value;
// this.searchAccountName = this.currentAccountName;
this.recid= event.detail.row.Id;
//console.log(recId);
//console.log(event.target.dataset.id);
//console.log(contacts1);
this.isModalOpen = true;
@wire (retrieveContactData,{keySearch:'$searchAccountName'})contacts;
console.log('hello');
console.log(data);
this.results = data;
this.error = error;
}*/
@wire(relatedContact,{accountid:'$recid'}) getAllAccounts;
// wiredAccount({error, data}){
// if(data){
// this.getAllAccounts = data;
// //this.getAllAccounts.data = data;
// //this.isData = true
// //console.log(this.getAllAccounts)
// console.log('hello world');
// console.log(data);
// }
// if(error){
// console.error(error)
// }
// }
//@wire (retrieveContactData,{keySearch:'$recName'})contacts;
closeModal() {
this.isModalOpen = false;
submitDetails() {
this.isModalOpen = false;
// @wire (retrieveContactData,{keySearch:'$searchAccountName'})contacts;
/*connectedCallback() {
TotalRecords().then(result=>{
this.v_TotalRecords = result;
});
previousHandler2(){
this.v_Offset = result;
// this.template.querySelector('c-paginator').changeView('trueprevious');
}else{
// this.template.querySelector('c-paginator').changeView('falsenext');
});
nextHandler2(){
this.v_Offset = result;
// this.template.querySelector('c-paginator').changeView('truenext');
}else{
// this.template.querySelector('c-paginator').changeView('falseprevious');
});
changeHandler2(event){
this.page_size = det;
firstpagehandler(){
this.v_Offset = 0;
// this.template.querySelector('c-paginator').changeView('trueprevious');
// this.template.querySelector('c-paginator').changeView('falsenext');
lastpagehandler(){
// this.template.querySelector('c-paginator').changeView('falseprevious');
// this.template.querySelector('c-paginator').changeView('truenext');
}*/
*).cls
@AuraEnabled
@AuraEnabled(cacheable=true)
@AuraEnabled(cacheable=true)
return contactList;
@AuraEnabled(cacheable=true)
return con1;
}
@AuraEnabled(cacheable=true)
v_Offset += v_pagesize;
return v_Offset;
@AuraEnabled(cacheable=true)
v_Offset -= v_pagesize;
return v_Offset;