You need to sign in to do that
Don't have an account?
kallam salesforce1
Unable to get lightning tag values by using queySelectorAll() in LWC?
HTML >>>
<template>
<div class="slds-m-top_medium slds-m-bottom_x-large">
<h2 class="slds-text-heading_medium slds-m-bottom_medium">
Button-icons with the <code>variant</code> attribute omitted or set to the default value of <code>border</code>.
</h2>
<!-- with border / by default -->
<div class="slds-p-around_medium lgc-bg">
<lightning-button-icon icon-name="utility:add" alternative-text="New Request" title="New request" onclick={showModalpopUp}></lightning-button-icon>
<template if:true={isModalpopupTrue}>
<!-- //<c-modal-popup-component></c-modal-popup-component> -->
<section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<!-- modal header start -->
<header class="slds-modal__header">
<button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={hideModalBox}>
<lightning-icon icon-name="utility:close"
alternative-text="close"
variant="inverse"
size="small" ></lightning-icon>
<span class="slds-assistive-text">Close</span>
</button>
<h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Leave Request</h2>
</header>
<!-- modal body start -->
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<lightning-record-edit-form object-api-name={objectApiName}
record-id={recordId} onsuccess={handleSuccess}>
<lightning-messages></lightning-messages>
<lightning-input-field field-name={user}> </lightning-input-field>
<lightning-input-field field-name={FromDate}> </lightning-input-field>
<lightning-input-field field-name={Todate}> </lightning-input-field>
<lightning-input-field field-name={Reason}> </lightning-input-field>
<lightning-button variant="brand" type="submit" name="save" label="Save">
</lightning-button>
<lightning-button type="submit" name="Cancel" label="Cancel" onclick={hideModalBox}>
</lightning-button>
</lightning-record-edit-form>
</div>
<!-- modal footer start
<footer class="slds-modal__footer">
<lightning-button variant="brand" type="submit" name="save" label="Save">
</lightning-button>
<button class="slds-button slds-button_neutral" onclick={hideModalBox}>Cancel</button>
</footer> -->
</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</template>
</div>
<div style="height: 300px;">
<lightning-datatable
key-field="id"
data={tabledata}
columns={columns}
hide-checkbox-column
onrowaction={handleRowAction}>
</lightning-datatable>
</div>
</div>
</template>
Js file >>>>>>>>>
showModalpopUp(){
this.isModalpopupTrue = true;
console.log('Get the details of Lig input tag >>>>>>'+this.template.querySelectorAll("lightning-input-field"));
this.template.querySelectorAll('lightning-input').forEach(element => {
element.value = null;
});
}
Getting error as >>
Get the details of Lig input tag >>>>>>SecureNodeList: [object NodeList]{ key: {"namespace":"c"} }
<template>
<div class="slds-m-top_medium slds-m-bottom_x-large">
<h2 class="slds-text-heading_medium slds-m-bottom_medium">
Button-icons with the <code>variant</code> attribute omitted or set to the default value of <code>border</code>.
</h2>
<!-- with border / by default -->
<div class="slds-p-around_medium lgc-bg">
<lightning-button-icon icon-name="utility:add" alternative-text="New Request" title="New request" onclick={showModalpopUp}></lightning-button-icon>
<template if:true={isModalpopupTrue}>
<!-- //<c-modal-popup-component></c-modal-popup-component> -->
<section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<!-- modal header start -->
<header class="slds-modal__header">
<button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={hideModalBox}>
<lightning-icon icon-name="utility:close"
alternative-text="close"
variant="inverse"
size="small" ></lightning-icon>
<span class="slds-assistive-text">Close</span>
</button>
<h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Leave Request</h2>
</header>
<!-- modal body start -->
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<lightning-record-edit-form object-api-name={objectApiName}
record-id={recordId} onsuccess={handleSuccess}>
<lightning-messages></lightning-messages>
<lightning-input-field field-name={user}> </lightning-input-field>
<lightning-input-field field-name={FromDate}> </lightning-input-field>
<lightning-input-field field-name={Todate}> </lightning-input-field>
<lightning-input-field field-name={Reason}> </lightning-input-field>
<lightning-button variant="brand" type="submit" name="save" label="Save">
</lightning-button>
<lightning-button type="submit" name="Cancel" label="Cancel" onclick={hideModalBox}>
</lightning-button>
</lightning-record-edit-form>
</div>
<!-- modal footer start
<footer class="slds-modal__footer">
<lightning-button variant="brand" type="submit" name="save" label="Save">
</lightning-button>
<button class="slds-button slds-button_neutral" onclick={hideModalBox}>Cancel</button>
</footer> -->
</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</template>
</div>
<div style="height: 300px;">
<lightning-datatable
key-field="id"
data={tabledata}
columns={columns}
hide-checkbox-column
onrowaction={handleRowAction}>
</lightning-datatable>
</div>
</div>
</template>
Js file >>>>>>>>>
showModalpopUp(){
this.isModalpopupTrue = true;
console.log('Get the details of Lig input tag >>>>>>'+this.template.querySelectorAll("lightning-input-field"));
this.template.querySelectorAll('lightning-input').forEach(element => {
element.value = null;
});
}
Getting error as >>
Get the details of Lig input tag >>>>>>SecureNodeList: [object NodeList]{ key: {"namespace":"c"} }
Try Below Example
Please mark it as best answer if it helps
Thank You!
@CharuDutt Thanks for the reply
I tried above one but still getting same error in console
Try Below Code
Please mark it as best answer if it helps
Thank You!