我使用闪电:recordViewForm从salesorce中的自定义对象加载某些记录,第一次通过此表单标签填充值,但我想刷新(重新加载)此表单以填充最新的数据库更改。请参阅代码段:
<aura:iteration items="{!v.orderWrapperList}" var="obj">
<!-- Display details of order -->
<lightning:card title="{!obj.Name}" iconName="standard:scan_card">
<lightning:recordViewForm aura:id="forceRecord" recordId="{!obj.Id}" objectApiName="Order__c">
<div class="slds-box slds-theme_default">
<lightning:outputField fieldName="Total_Amount__c" />
<lightning:outputField fieldName="Score__c" />
<lightning:outputField fieldName="Status__c" />
</div>
</lightning:recordViewForm>
<div align="center" draggable="false" >
<lightning:button variant="brand" label="Cancel" onclick="{! c.reDirect }" />
<lightning:button variant="brand" label="Submit" onclick="{! c.openModel }" />
</div>
</lightning:card>
</aura:iteration>
refresh : function(component, event, helper) {
var action = cmp.get('c.myController');
action.setCallback(cmp,
function(response) {
var state = response.getState();
if (state === 'SUCCESS'){
$A.get('e.force:refreshView').fire();
} else {
//do something
}
}
);
$A.enqueueAction(action);
}
要刷新视图,请运行$ A.get(“e.force:refreshView”)。fire();,它会重新加载视图的所有数据。
欲了解更多信息:https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_refreshView.htm