I need to delete a row in a table who is bind with jModel when I click in the trash button.
This is my data:
_data: {
requestSpecific: [{nArt= "A002", name="Computador, quantity=2},{},{...}],
items: [],
partner: [],
vatGroups: [],
countries: [],
totals: [],
ttlstotais: []
},
model name is jModel. Maybe I have some mistakes in the model in here, but it's rigth on the code.
The table is a grid table in Single mode.
This is my event for the button "trash".
onDelArtigoPress: function (oEvent) {
var iIndex = oTable.getSelectedIndex();
var jData = this.jModel.getProperty("/requestSpecific");
var sMsg;
if (iIndex < 0) {
sMsg = "Please, select an item to be deleted";
} else {
//// 1st delete the object in the model
//// 2nd refresh the model, It will automaticaly update the table
}
}
I don't know how to do the 1st step. I know that I need to use the splice prototype, but I don't know how to get the position of the object in the array (jModel).
If you can help me....!
I found the solution.
onDelArtigoPress: function (oEvent) {
var oTable = this.byId("tableArtigoId");
var iIndex = oTable.getSelectedIndex();
var sMsg;
if (iIndex < 0) {
sMsg = "Sem nenhuma linha selecionada";
MessageToast.show(sMsg);
} else {
var oData = this._data.requestSpecific;
oData.splice(iIndex, 1);
this.jModel.setProperty("/requestSpecific", oData);
}
},
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.