我已經使用「雙向」綁定將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");
有什麼在設置未決?爲了更新表格中的多個記錄,我必須使用一些批處理操作嗎?任何幫助,將不勝感激。
由於
感謝瑪雅,說的對。我現在不使用「雙向」綁定。而不是我寫的更改事件處理程序的表格上的所有列的火我正在添加一個批處理操作,並點擊另一個「保存」按鈕,我已經在屏幕上,我提交批處理。 – Supereme