on 05-03-2018 4:20 PM
Hi,
When you display import error, the error message for all records
I'm importing the records from a .CSV file into an oData Model and if the records do not have any errors they import normally, but if one of the records has an error it considers the same record for all create options.
onImportCSV: function(event) {
var self = this;
var oModelAdmin = this.getModel("admin");
var oView = this.getView();
var oTable = oView.byId("idTable");
var aIndices = oView.byId("idTable").getSelectedIndices();
oMessages = [];
if (aIndices.length < 1) {
MessageToast.show("Não existem items selecionados");
} else {
for(var i = 0; i < aIndices.length; i++ ) {
var oEntry = {};
oEntry.id = oTable.getRows()[oTable.getSelectedIndices()[i]].getCells()[0].getText();
oEntry.nome = oTable.getRows()[oTable.getSelectedIndices()[i]].getCells()[1].getText();
oEntry.email = oTable.getRows()[oTable.getSelectedIndices()[i]].getCells()[2].getText();
oEntry.ativo = oTable.getRows()[oTable.getSelectedIndices()[i]].getCells()[3].getText();
oEntry.super_usuario = oTable.getRows()[oTable.getSelectedIndices()[i]].getCells()[4].getText();
oEntry.csv = "1";
oModelAdmin.create("/Usuario", oEntry, {
success: function(data) {
MessageToast.show("Usuário (" + oEntry.id + ") salvo com sucesso!!!");
},
error: function(error) {
console.log(oEntry);
MessageToast.show("[" + error.statusCode + " - " + error.statusText + "] " + error.responseText); }
});
}
}
}
Because it ignores the correct record and applies the failed record to all interactions
Sorry for bad english.
Hi,
Why are you getting the table data like this .. ?? Why are you not using models ??
thanks
Viplove
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh than how did you import, you might have read the data from excel and bind it to the table using models ? Correct ?? if thats the case than you can get the items which you select and than for each item you can get the bindingContext to get the values and than add it to the odata request ..
This is how you need to do it ..
User | Count |
---|---|
81 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.