I'm using lightning:recordViewForm and I realized that there is a bit delay. I was reading a lot here and in google but can't find any solution to this.

I thought on adding a spinner on my component just to be a little bit user friendly meanwhile data is loading.

Do you have any idea to implement it?

<lightning:recordViewForm aura:id="auraID"
                                  density="comfy" >
            <div class="slds-grid slds-wrap">
                <div class="slds-col slds-size_3-of-12">
                    <lightning:outputField variant="label-stacked" fieldName="any_field"/>
                <div class="slds-col slds-size_3-of-12">
                    <lightning:outputField variant="label-stacked" fieldName="Tother__c"/>

                <div class="slds-col slds-size_6-of-12">
                    <lightning:outputField variant="label-stacked" fieldName="thelast__c"/>

For this purpose, you will need onload event. But this event is not available on recordViewForm - you can instead use recordEditForm.

Here is the sample code:

<lightning:spinner aura:id="spinner" variant="brand" />

<lightning:recordEditForm recordId="{!v.recordId}" 
    <lightning:messages />
    <lightning:outputField fieldName="Name" />


handleLoad : function(component, event, helper){
    $A.util.addClass(component.find("spinner"), "slds-hide");    
  • Thanks salesforce-sas for your soon reply. Using editForm is a way to solve but i'm not sure if the best. Aug 23 '19 at 15:53
  • 1
    As you can see in the documentation, we can use outputField also - there is absolutely no problem. Note that this form uses LWC form (shown in doc link) behind the scenes (confirmed from sf support - unofficial). Aug 26 '19 at 8:01

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.