Lightning:recordForm - Lightning Data Service
Lightning:recordForm is a very powerful component for editing, viewing and adding a record in lightning and combines both lightning:recordEditForm and lightning:recordViewForm.
Here is an example lightning component for lightning:recordForm.
Lightning Component:-
<aura:component implements="flexipage:availableForRecordHome,force:hasSObjectName,force:hasRecordId" access="global" >
<aura:attribute name="fieldsList" type="String[]" default="['Id', 'Name', 'BillingAddress', 'Phone' , 'Type']"/>
<div class="THIS">
<lightning:recordForm
recordId="{!v.recordId}"
objectApiName="{!v.sObjectName}"
fields="{!v.fieldsList}"
columns="2"
mode="View"
onsuccess="{!c.myAction}"/>
</div>
</aura:component>
JavaScrip Controller:-
({
myAction : function(component, event, helper) {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Success!",
"message": "Record is successfully updated!",
"type": "success"
});
toastEvent.fire();
}
})
CSS:-
.THIS {
background:white
}
OutCome:-
If you click on inline edit icon then action changes from Edit mode to View mode.
Here is an example lightning component for lightning:recordForm.
Lightning Component:-
<aura:component implements="flexipage:availableForRecordHome,force:hasSObjectName,force:hasRecordId" access="global" >
<aura:attribute name="fieldsList" type="String[]" default="['Id', 'Name', 'BillingAddress', 'Phone' , 'Type']"/>
<div class="THIS">
<lightning:recordForm
recordId="{!v.recordId}"
objectApiName="{!v.sObjectName}"
fields="{!v.fieldsList}"
columns="2"
mode="View"
onsuccess="{!c.myAction}"/>
</div>
</aura:component>
JavaScrip Controller:-
({
myAction : function(component, event, helper) {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Success!",
"message": "Record is successfully updated!",
"type": "success"
});
toastEvent.fire();
}
})
CSS:-
.THIS {
background:white
}
OutCome:-
If you click on inline edit icon then action changes from Edit mode to View mode.
original site cheapjerseysatusa,cheapjerseys100,cheapjerseys100,tobuycheapjerseys,nflcheapjerseys2013,cheap-jerseys-2013,cheapjerseyszl,vipjerseyforsale,usjerseyshop
ReplyDelete