on 10-08-2021 11:30 AM
Hi,
I have a problem, inserting a new line into a sap.m.table, without sending it immediately to the backend.
When I click on an insert button, I open a value help, where the user can select components which he wants to insert into the table.
This is the code, which inserts the values into the table:
var sNewComponent =
"ServiceOrderComponents(Activity='" +
this._sActivity +
"',OrderId='" +
this._sOrderId +
"',Material='" +
sMaterialNo +
"')";
var bExisting = false;
for (var i = 0; i < oRow.ToComponents.__list.length; i++) {
if (
sNewComponent ==
this._oDataModel.getProperty("/" + oRow.ToComponents.__list[i])
) {
bExisting = true;
}
}
if (bExisting === false) {
oRow.ToComponents.__list.push(sNewComponent);
//}
var oParentContext = this._oDataModel.createEntry(sNewComponent, {
//refreshAfterChange: false,
//groupId: "groupID1",
properties: {
Activity: this._sActivity,
IsChanged: false,
Plant: "1200",
ReservationNo: "",
StorageLocation: sStorageLocation,
OrderId: this._sOrderId,
ReservationPosition: "",
ReadOnly: false,
Material: sMaterialNo,
MaterialDescription: sMaterialDescription,
Price: "0.00",
PriceUnit: "1.000",
RequirementQuantity: "1",
RequirementQuantityUnit: sBaseUnit,
Currency: "EUR",
},
success: function (oEvent) {
var x = 1;
},
error: function (oEvent) {
var y = 2;
},
});
var listItemForTable = this.getView()
.byId("idServiceOrderComponentsListItem")
.clone();
listItemForTable.setBindingContext(oParentContext);
oServiceOrderComponents.addItem(listItemForTable);
}
}
The components are inserted, but when I change anything for another component in the same table, the data of the inserted component disappears. The rows stays, but is empty. Binding is set to TwoWay in the manifest.json, refreshAfterSave is false.
Has anybody an idea, why the inserted data disappears.
Thanks
Marcus
it is just not a supported scenario.
we did the following to make it work(our scenario is very simple, only one editable field, plain input field).
1. create entry
2.attach the context as custom data to the new line(in our case we have only one editable field, so context is attached to this field), don't bind context to this new line
3.manually track the change, put them into a array
{path:context.getPath()+"/COLUMNNAME",
value:value
}
4. when you save
loop through the array.
oDatamodel.setProperty(iteminthearray.path,
iteminthearray.value
)
finally
oDatamodel.submit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
9 | |
9 | |
8 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.