Lightning Component Using RecordEdit and RecordView
Lightning componet:
<aura:component implements="force:appHostable,force:lightningQuickAction,force:hasRecordId,flexipage:availableForRecordHome">
<aura:attribute name="flag" type="boolean" default="true" />
<aura:attribute name="recordId" type="Id"/>
<article class="slds-card">
<aura:if isTrue="{!v.flag}">
<force:recordView recordId="{!v.recordId}" type="FULL"/>
<aura:set attribute="else">
<force:recordEdit aura:id="edit" recordId="{!v.recordId}"/>
</aura:set>
</aura:if>
<button class="slds-button slds-button_neutral">Cancel</button>
<aura:if isTrue="{!!v.flag}">
<ui:button label="Save" press="{!c.save}"/>
</aura:if>
<aura:if isTrue="{!v.flag}">
<ui:button label="Edit" press="{!c.edit}"/>
</aura:if>
</article>
</aura:component>
JavaScrio Controller
({
save : function(component, event, helper) {
component.find("edit").get("e.recordSave").fire();
component.set("v.flag",true);
},
edit : function(component, event, helper) {
component.set("v.flag",false);
}
})
<aura:component implements="force:appHostable,force:lightningQuickAction,force:hasRecordId,flexipage:availableForRecordHome">
<aura:attribute name="flag" type="boolean" default="true" />
<aura:attribute name="recordId" type="Id"/>
<article class="slds-card">
<aura:if isTrue="{!v.flag}">
<force:recordView recordId="{!v.recordId}" type="FULL"/>
<aura:set attribute="else">
<force:recordEdit aura:id="edit" recordId="{!v.recordId}"/>
</aura:set>
</aura:if>
<button class="slds-button slds-button_neutral">Cancel</button>
<aura:if isTrue="{!!v.flag}">
<ui:button label="Save" press="{!c.save}"/>
</aura:if>
<aura:if isTrue="{!v.flag}">
<ui:button label="Edit" press="{!c.edit}"/>
</aura:if>
</article>
</aura:component>
JavaScrio Controller
({
save : function(component, event, helper) {
component.find("edit").get("e.recordSave").fire();
component.set("v.flag",true);
},
edit : function(component, event, helper) {
component.set("v.flag",false);
}
})
Comments
Post a Comment