function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shuhbam SinhaShuhbam Sinha 

how to hide field from this.template.queryselectorall in lwc

Hello Everyone,
I have one requirement where I need to hide field after quering 'this.template.queryselectorall' once the queried field matches with some condition like.
this.template.querySelectorAll('lightning-input-field').forEach((field) => {
                                if (field.fieldName ==  Some condition ') {
                                    field.disabled = true;
                                    field.required = false;
                                    field.value = null;
                                }

                            });
                        }
On the above code I am making the field non required and disabled but I need to hide the fields here .I tried many ways but no luck and I need to hide with the help of 'this.template.querySelectorAll('lightning-input-field')' only . Is there any way to do the same. Please help me on this. Thanks in advance.
SubratSubrat (Salesforce Developers) 
Hello Shuhbam ,

Can you try putting the style.display property to none.
 
this.template.querySelectorAll('lightning-input-field').forEach((field) => {
    if (field.fieldName == Some condition) {
        field.style.display = 'none';
    }
});

Hope the above helps !
Thank you.