[英]Get value property from table sapui5
I want to delete data by row in my table sapui5 but have an error. 我想在我的表sapui5中按行删除数据但是有错误。 I have table with id name "tableKelompokPeserta".
我的表名为“tableKelompokPeserta”。
code: 码:
deleteButton2 : function(){
var oTable = this.getView().byId("tableKelompokPeserta");
oTable.attachRowSelectionChange(function(oEvent){
var currentRowContext = oEvent.getParameter("rowContext");
var selData = extModel.getProperty("template", currentRowContext);
console.log(selData);
sap.m.MessageToast.show(currentRowContext);
});
},
onInit : function (){
var router = sap.ui.core.UIComponent.getRouterFor(this);
var uri = "http://172.16.50.202:8081/id/co/taspen/joinDevelopment/modules/tks_mantab/service.xsjs?cmd=get";
var jsonMod = new sap.ui.model.json.JSONModel(uri,true);
var oTable = this.getView().byId("tableKelompokPeserta");
oTable.setModel(jsonMod);
var oColumn1 = new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text: "KODE KELOMPOK",
textAlign : "Center"}),
template : new sap.ui.commons.TextField().bindProperty("value", "KODE_KELOMPOK"),
sortProperty : "KODE_KELOMPOK",
filterProperty : "KODE_KELOMPOK"
});
var oColumn2 = new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text: "NAMA",
textAlign : "Center"}),
template : new sap.ui.commons.TextField().bindProperty("value", "NAMA"),
sortProperty : "NAMA",
filterProperty : "NAMA"
});
var oColumn3 = new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text: "MINIMAL USIA MASUK",
textAlign : "Center"}),
template : new sap.ui.commons.TextField().bindProperty("value", "MINIMAL_USIA_MASUK"),
sortProperty : "MINIMAL_USIA_MASUK",
filterProperty : "MINIMAL_USIA_MASUK"
});
var oColumn4 = new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text: "MAKSIMAL USIA MASUK",
textAlign : "Center"}),
template : new sap.ui.commons.TextField().bindProperty("value", "MAKSIMAL_USIA_MASUK"),
sortProperty : "MAKSIMAL_USIA_MASUK",
filterProperty : "MAKSIMAL_USIA_MASUK"
});
var oColumn5 = new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text: "TERUSAN",
textAlign : "Center"}),
template : new sap.ui.commons.TextField().bindProperty("value", "TERUSAN"),
sortProperty : "TERUSAN",
filterProperty : "TERUSAN"
});
var oColumn6 = new sap.ui.table.Column({
label : "ACTION",
template : new sap.ui.commons.Button({
icon : "sap-icon://edit",
tooltip : "{KODE_KELOMPOK}",
press : function(){
var id = this.getTooltip();
}
})
});
oTable.addColumn(oColumn1);
oTable.addColumn(oColumn2);
oTable.addColumn(oColumn3);
oTable.addColumn(oColumn4);
oTable.addColumn(oColumn5);
oTable.addColumn(oColumn6);
oTable.bindRows("/d/results");
}
I have 6 columns and I want to get "KODE_KELOMPOK" column selected row (single selection only). 我有6列,我想获得“KODE_KELOMPOK”列选择行(仅限单选)。 I want when click deletebutton2, I get "KODE_KELOMPOK" (from oColumn1).
我想点击deletebutton2时,我得到“KODE_KELOMPOK”(来自oColumn1)。 and how to disable multiple row in sapui5?
以及如何在sapui5中禁用多行? Thank you.
谢谢。
Regards, 问候,
Bobby 鲍比
For your first question, in your deleteButton2
event handler, use the oEvent
object to get the row of the pressed delete button: 对于第一个问题,在
deleteButton2
事件处理程序中,使用oEvent
对象获取按下的删除按钮的行:
deleteButton2 : function(oEvent){
var sValue = oEvent.getSource().getParent().getBindingContext().getProperty("KODE_KELOMPOK");
}
sValue
will contain the value of the KODE_KELOMPOK
model property for the selected row. sValue
将包含的值KODE_KELOMPOK
对于选择的行模型属性。
For your second question, list selection mode can be set using the mode
property of the List
control. 对于第二个问题,可以使用
List
控件的mode
属性设置列表选择模式。 Supported values can be found here . 支持的值可以在这里找到。
SingleSelectMaster
seems to be good for you. SingleSelectMaster
似乎对你有好处。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.