Odata 编辑表中的多行

Odata 编辑表中的多行,odata,sapui5,Odata,Sapui5,我用“双向”装订法把ODataModel和桌子绑在一起。我需要允许用户编辑表格底部有“保存”按钮的行。目前,尽管表格是可编辑的,但我无法编辑表格多行中的条目。 请在下面找到我的代码: var oTable = new sap.ui.table.Table("dprTable",{ visibleRowCount: 4, visible: true, navigationMode: sap.ui.table.NavigationMode.Pagina

我用“双向”装订法把ODataModel和桌子绑在一起。我需要允许用户编辑表格底部有“保存”按钮的行。目前,尽管表格是可编辑的,但我无法编辑表格多行中的条目。
请在下面找到我的代码:

var oTable = new sap.ui.table.Table("dprTable",{
        visibleRowCount: 4,
        visible: true,
        navigationMode: sap.ui.table.NavigationMode.Paginator
    });

    var oColumn = new sap.ui.table.Column({
        label: new sap.ui.commons.Label({text: "DBR/DPR"}),
        template: new sap.m.Link({
            "target": "_blank",
            press:[controller.onClickDemoNo,controller]

        }).bindProperty("text","DemoId"),
        width: "auto",
        tooltip: "DBR/DPR"
    });

    oTable.addColumn(oColumn);

    oTable.addColumn(new sap.ui.table.Column({
        label: new sap.ui.commons.Label({text: "Description"}),
        template: new sap.ui.commons.TextView().bindProperty("text", "DemoDesc"),
        width: "auto",
        tooltip: "Description"

    }));

    oTable.addColumn(new sap.ui.table.Column({
        label: new sap.ui.commons.Label({text: "Required Date"}),
        template: new sap.ui.commons.DatePicker("",{
            value:{
                path:"ReqDate",
                type: new sap.ui.model.type.Date({pattern: "dd-MM-yyyy"})
            },
            change: function(){
                console.log('the date is changed and it\'s value is'+value);
            },


        }),
        width: "auto",
        tooltip: "Required Date"
    }));


    oTable.addColumn(new sap.ui.table.Column({
        label: new sap.ui.commons.Label({text: "Requestor"}),
        template: new sap.ui.commons.TextView().bindProperty("text", "RequestorName"),
        width: "auto",
        tooltip: "Requestor"

    }));

    oTable.addColumn(new sap.ui.table.Column({
        label: new sap.ui.commons.Label({text: "Requestor/Project Lead"}),
        template: new sap.ui.commons.TextView().bindProperty("text", "LeadName"),
        width: "auto",
        tooltip: "Requestor/Project Lead"

    }));

    oTable.addColumn(new sap.ui.table.Column({
        label: new sap.ui.commons.Label({text: "Solution"}),
        template: new sap.ui.commons.TextView().bindProperty("text", "SolutionText"),
        width: "auto",
        tooltip: "Solution"

    }));



    oTable.addColumn(new sap.ui.table.Column({
        label: new sap.ui.commons.Label({text: "Start Date"}),
        template: new sap.ui.commons.DatePicker("",{
            value:{
                path:"StartDate",
                type: new sap.ui.model.type.Date({pattern: "dd-MM-yyyy"})
            }
        }),
        width: "auto",
        tooltip: "Start Date"

    }));

    oTable.addColumn(new sap.ui.table.Column({
        label: new sap.ui.commons.Label({text: "End Date"}),
        template: new sap.ui.commons.DatePicker("",{
            value:{
                path:"StartDate",
                type: new sap.ui.model.type.Date({pattern: "dd-MM-yyyy"})
            }
        }),
        width: "auto",
        tooltip: "End Date"

    }));

    oTable.addColumn(new sap.ui.table.Column({
        label: new sap.ui.commons.Label({text: "Estimated Duration"}),
        template: new sap.ui.commons.TextView().bindProperty("text", "EstDuration"),
        width: "auto",
        tooltip: "Estimated Duration"

    }));

    oTable.addColumn(new sap.ui.table.Column({
        label: new sap.ui.commons.Label({text: "Hours"}),
        template: new sap.m.Input("",{}).bindProperty("value", "ActDuration"),
        width: "auto",
        tooltip: "Hours"

    }));

    oTable.addColumn(new sap.ui.table.Column({
        label: new sap.ui.commons.Label({text: "Status"}),
        template: new sap.ui.commons.ComboBox({items: [
            new sap.ui.core.ListItem({text: "New",key:"1"}),
            new sap.ui.core.ListItem({text: "In Process",key:"2"}),
            new sap.ui.core.ListItem({text: "Completed",key:"3"})
        ]}).bindProperty("value","StatusText"),
        width: "auto",
        tooltip: "Status"

    }));

    oTable.setBusyIndicatorDelay(1);
    //oData service call

    var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZSECENTRAL_SRV",true);
    oModel.setDefaultBindingMode("TwoWay");
    oModel.attachRequestSent(function (oEvent) {
        console.log('request sent');
         oTable.setBusy(true);
    });
    oModel.attachRequestCompleted(function () {
            console.log('request completed');
            oTable.setBusy(false);

    });
    oModel.attachRequestFailed(function () {
              oTable.setBusy(false);
    });

    oTable.setModel(oModel);
    oTable.bindRows("/DEOPENDBRSet");
设置中是否有挂起的内容?要更新表中的多个记录,我必须使用一些批处理操作吗?任何帮助都将不胜感激


感谢OData,一个http请求只能包含一个CRUD操作,除非使用批处理。因此,对于多个记录更新,建议使用批处理。我有同样的问题,我仍在寻找解决方案。 您最初的问题将在此处解释:

我仍在搜索的是,如何使用一个模型的多个更改(在不同的对象/实体中)触发“一个”批处理请求

我希望有这样的情况: oModel.applychangesbatch()

其中,对现有元素的所有更改都是通过绑定控件完成的。 当然,对于新创建的实体,必须先在模型上调用另一个来创建实体


换句话说:是否有一种方法可以对模型使用普通绑定,并告诉模型在一个请求(可能是批处理)中将所有更改发送到服务器,以便服务器能够存储“全部”或“无”?

谢谢Maya,right说。我现在不使用“双向”绑定。我没有为表中的所有列编写更改事件处理程序,而是为表中的所有列添加了一个批处理操作,并单击屏幕上的另一个“保存”按钮,提交了批处理。