LoginSignup
0
0

More than 1 year has passed since last update.

親子の参照関係の画面のリフレッシュ

Posted at

ちょっとしたコンポーネントを作成して入力を便利にしたいと思います。
商談の代わりに使う予定の案件管理オブジェクト(青色の枠)と売上予定月を複数入力できるように別のオブジェクト(緑色の枠)を作って親子の関係にしました。(実際には合計を簡単に出したかったので積み上げ集計項目を使うために主従関係にしています)

image.png

本当だったら、赤色の枠のような入力画面ですが... 年月度は自動で受注日の2年先を表示したいのでauraコンポーネントで作ってみました。

image.png

まぁ、簡単にできたのですがカスタムコンポーネントで子オブジェクトを登録しても積み上げ集計項目が変わりません。
あああ、F5を押して再ロードするとちゃんと合計が変わっています。ということは子オブジェクトを登録/修正したらリフレッシュさせればいいんだな。

ということで、保存処理の中に $A.get('e.force:refreshView').fire();を追加。
うまく機能しました。ただし、このカスタムコンポーネントは再描画しませんね。
仕方ないのでちゃんとlightning:tableにApexから最新のデータを渡します。
$A.get('e.force:refreshView').fire();は標準画面にしか適用されないのだろうか?

    saveTable: function(component, event, helper) {
        var editedRecords =  component.find("myDataTable").get("v.draftValues");
        //alert(JSON.stringify(editedRecords));
        var recordId = component.get("v.recordId");
        var action = component.get("c.editProspect");
        action.setParams({
            "editedRecords" : editedRecords,
            "recordId":recordId
        });action.setCallback(this,function(response) {
            var ResponseDto = response.getReturnValue();
            //alert(action.getState());
            //alert(ResponseDto.isSuccess);
            if (action.getState() == "SUCCESS" && ResponseDto.isSuccess) { 
                //if update is successful
                helper.showToast({
                    "title": "Record Update",
                    "type": "success",
                    "message": ResponseDto.values.Msg
                });
                helper.getRecord(component, event);//このコンポーネントの再描画
                $A.get('e.force:refreshView').fire();//親画面の再描画

            }  else if (action.getState() == "ERROR" || !ResponseDto.isSuccess) { 
                helper.showToast({
                    "title": "Error!!",
                    "type": "error",
                    "message": "Error in update"
                });                
            }
        });
        $A.enqueueAction(action);
    },
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0