在SAP UI5中预填充具有两个键的行(项目)的“编辑”页面

时间:2018-07-19 20:08:07

标签: odata sapui5

这是我的商品级别页面,其中有两个键[/b]

通过选择项目并按下Request ID , Profile ID按钮,我应该显示包含数据的编辑页面。

enter image description here

Edit按的代码

Edit Button

我在这里

  

sObjectPath =“ ZRECRUITMENT_CANDIDATESet(RegNo = 1,ProId = 1)”

我的 manifest.json

this.getRouter().getTargets().display("CreateCandidate", {
            mode: "update",
            objectPath: sObjectPath
        });

"CreateCandidate":{ "viewName": "CreateCandidate", "viewId": "cand_creation", "viewLevel":2 }, 页中,我应该绑定到edit的内容是什么,我应该是编辑页面的模式URL。

对于标题行,我们将提供FORM种。

但是如果我们有两个键,我们将如何给出Pattern。像ZENTITY_SET/1吗?请为此指导我

我的ODATA读取查询:

ZENTITY_SET/1/2

我的OData响应:

/sap/opu/odata/SAP/ZRECRUITMENT_TRACKER_APP_SRV/
ZRECRUITMENT_CANDIDATESet(RegNo=1,ProId=2)?$format=xml

2 个答案:

答案 0 :(得分:2)

请参阅文档以配置路由器 here

在manifest.json中:

...
"routes" : [
    {
        name: "createCandidate",
        pattern: "create/{RegNo}-{ProId}",
        target: "CreateCandidate"
    }
],
"targets": {
    "CreateCandidate": {
        "viewName": "CreateCandidate",
        "viewLevel": 2
},
....

然后导航至该视图:

oRouter.navTo("createCandidate", {
    RegNo: 1
    ProId: 1
})

然后在CreateCandidate控制器中

_onPatternMatched: function(oEvent) {
    // get the params RegNo and ProId from the event object - {RegNo: 1, ProId: 1}
    var oArgs = oEvent.getParameter("arguments"); 

    //use the ODataModel to create a binding path from the values
    var sBindingPath = this.getView().getModel().createKey("/ZRECRUITMENT_CANDIDATESet", oArgs);

    //Bind your view to the binding path
    this.getView().bindElement(sBindingPath); 
}

onInit: function() {
     //get the route object from the router
     var oRoute = this.getOwnerComponent().getRouter().getRoute("createCandiate");

     //attach an event to the route which is fired when the route pattern is matched
     oRoute.attachPatternMatched(this._onPatternMatched, this);
}

答案 1 :(得分:1)

您是否使用ob_start(ob_gzhandler)函数?如果是这样,并且如果在ob_start(ob_gzhandler)函数上方输出任何内容,则会收到此错误。您不能使用此功能或在此功能上方不输出内容。 ob_gzhandler回调函数将确定浏览器将接受哪种类型的内容编码,并相应地返回其输出。因此,如果在此函数上方输出内容,则内容的编码可能与ob_gzhandler的输出内容不同,从而导致此错误。