on 2020 Jul 01 8:52 PM
Hi there.
I've a master-detail app where the master view has a list and the detail view has an editable form. The navigation and all that works fine, but I've an issue with the data protection/data loss mechanism.
If I select item 1 in the master list, make some changes in the detail view, then press item 2 in the master list, I get a browser pop-up; "This page contain unsaved data..."
If I click OK, all is well. (This is handled in the display controller and irrelevant to this issue.)
If I click Cancel, the navigation to the selected list item is cancelled and the detail view is not changed. However; the list in the master now has the item I clicked highlighted, not the item that is still in the detail view.
In my Master view:
<List items="{/RecordSet}" selectionChange="handleSelectionChange" mode="SingleSelectMaster">
<StandardListItem title="{Field1}" description="{Field2}" type="Navigation"/>
</List>
In my Master controller:
handleSelectionChange: function (oEvent) {
// Set the app's Dirty State.
sap.ushell.Container.setDirtyFlag(this.getOwnerComponent().getModel().hasPendingChanges());
// Navigate to the selected item. This does not happen if SetDirtyFlag(true).
this.getRouter().navTo("edit", {
Id: oEvent.getParameter("listItem").getBindingContext().getProperty("Field3")
);
}
Is there a way to prevent the sap.m.List highlighting the selected record when the navigation is cancelled?
I think I've looked myself blind on this issue, so I'm asking you people!
Thanks,
Thomas
Request clarification before answering.
I don't think there is an out of box solution for this, you probably have to do this manually in below ways
1. Read the url hash parameters to identify the item and set the selected item again in the list.
Or
2. Persist the item in the master page in controller global variable and pass that item to set selected item in case of cancel.
-Mahesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
53 | |
8 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.