最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - SAP UI5 How to refresh the model data in table - Stack Overflow

programmeradmin4浏览0评论

I have a sap.ui.Table with 10 records. If I perform any operation on that sap.ui.Table like Submit by selecting a particular row, operation should perform and Row should get removed from the table. Row data is getting submitted but row is not getting removed from the table. I tried by refreshing the table. But didn't worked for me. Below is the piece of code.

            this.oDataModel.create("/testService", dataToSend, {
            success: function(data, resp) {                 
                var oXML = jQuery.parseXML(resp.headers["sap-message"]);
                var oXMLMsg = oXML.querySelector("message");
                var response = oXMLMsg.textContent;
                MessageBox.success(response);

                var listBinding = this.getView().byId("idLeaveTable");
                var leaveModel = listBinding.getModel("approvalModel");
                leaveModel.refresh(true);
                that.successApprovalModel();
            },
            error: function(err) {
                var oXML = jQuery.parseXML(err.response.body);
                var oXMLMsg = oXML.querySelector("message");
                MessageBox.error(oXMLMsg.textContent);
            }
        });

Here if iam submitting any row to backend service then corresponding row should get removed from both table and model. As of now it is not happening. But if im reloading the application then the corresponding row is getting removed.

Can some one please help me to resolve the issue.

Thank you in advance

I have a sap.ui.Table with 10 records. If I perform any operation on that sap.ui.Table like Submit by selecting a particular row, operation should perform and Row should get removed from the table. Row data is getting submitted but row is not getting removed from the table. I tried by refreshing the table. But didn't worked for me. Below is the piece of code.

            this.oDataModel.create("/testService", dataToSend, {
            success: function(data, resp) {                 
                var oXML = jQuery.parseXML(resp.headers["sap-message"]);
                var oXMLMsg = oXML.querySelector("message");
                var response = oXMLMsg.textContent;
                MessageBox.success(response);

                var listBinding = this.getView().byId("idLeaveTable");
                var leaveModel = listBinding.getModel("approvalModel");
                leaveModel.refresh(true);
                that.successApprovalModel();
            },
            error: function(err) {
                var oXML = jQuery.parseXML(err.response.body);
                var oXMLMsg = oXML.querySelector("message");
                MessageBox.error(oXMLMsg.textContent);
            }
        });

Here if iam submitting any row to backend service then corresponding row should get removed from both table and model. As of now it is not happening. But if im reloading the application then the corresponding row is getting removed.

Can some one please help me to resolve the issue.

Thank you in advance

Share Improve this question edited Apr 27, 2018 at 5:17 user2644620 asked Apr 26, 2018 at 11:06 user2644620user2644620 1992 gold badges13 silver badges39 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 1

Can you try this:

this.byId("lineItemsList").getBinding("items").refresh();

For the oData model you should use the method 'remove' to trigger a DELETE request to the oData service. The 'create' method triggers a POST request.

发布评论

评论列表(0)

  1. 暂无评论