如何在oracle-jet中刷新表oj-table组件?

时间:2019-02-18 14:43:46

标签: javascript oracle-jet

我正在将数据添加到API,并且希望我的oj表显示它。如何刷新oracle-jet中的特定组件?

我正在使用oracle-jet v6.1.0开发一个应用程序,在这里我使用本地api获取和存储数据并使用表格显示它。我发送了POST请求,并且数据存储在数据库中,并且在回调函数中,我转到了表格页面,但是我没有得到新的行!

当我单击提交按钮时,此功能:

   self.submitopportunity = function() {

        var dataObj = {
            "projectName": self.custProject(),
            "department": self.custDepartements(),
            "type": self.srtVal(),
            "budget": self.custBudget(),
            "description": self.solutionVal(),
            "closeDate": self.closeDate(),
            "customer": self.nameVal(),
            "product": self.productVal(),
            "status":  self.statusVal(),
            "contact": self.contactVal(),
            "favorite": false
        };
        console.info(dataObj);
        $.ajax({
            url: url + '/opportunity',
            type: "POST",
            data: JSON.stringify(dataObj),
            contentType: 'application/json',
            success: function (response) {
                oj.Router.rootInstance.go("opportunities");
                return true;
            },
            error: function(error){
                console.log("Something went wrong", error);
            }
        })

    };

刷新页面时,将添加新行。那么如何同步或刷新oj-table组件呢?

1 个答案:

答案 0 :(得分:2)

所有oracle JET组件都具有“刷新”功能。只需这样做:

document.getElementById('yourtableid').refresh();

要在导航到表格页面后立即更新组件,需要使用oj.Router的{​​{1}}方法returns a Promise的事实。我们可以使用回调刷新表。

go