【问题标题】:How to reload RecordViewForm in Salesforce lightning component?如何在 Salesforce 闪电组件中重新加载 RecordViewForm?
【发布时间】:2018-08-30 04:55:54
【问题描述】:

我正在使用 Lightning:recordViewForm 从 salesorce 中的自定义对象加载某些记录,这是第一次通过此表单标签填充值,但我想刷新(重新加载)此表单以填充最新的数据库更改。请参阅代码 sn-p :

<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>

【问题讨论】:

  • 那么你想如何重新加载它?通过一个按钮点击like-click并从数据库中获取最新的对象?
  • 是的,“提交”按钮正在执行一些数据库提交,然后我想向用户显示更改后的值。

标签: salesforce refresh reload


【解决方案1】:
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

【讨论】:

  • 上述解决方案是再次加载组件但数据没有改变。可能我们需要使用其他东西来刷新 "recordViewForm" 。谢谢!
  • 你能告诉我你到底想做什么或者如果你分享一些sn-p会更有帮助
  • 这个方法重新加载整个页面,而不是闪电:recordViewForm
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-06-15
  • 1970-01-01
  • 2018-04-16
  • 2020-01-26
  • 2022-09-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多