on 03-15-2019 10:08 AM
Hello experts,
I am currently trying to find a solution for keeping the state (expanded / collapsed) of nodes from a sap.ui.table.TreeTable after saving changes done to TreeTable entries to the BE.
Scenario: I have a TreeTable binded to an OData v2 webservice with operationMode='Client' on SAPUI5 v 1.52.13. There are different properties of the TreeTable entries that can be changed by users (e.g.: a user can set a new price for an entry in the table).
The issue: After saving the changes done to the TreeTable entries, the table is triggering a request to the BE to reload the data. At this point, the state of the TreeTable is reset. The nodes that were expanded or collapsed are restored to their initial state.
Looking into the corresponding SAPUI5 documentation I noticed there is a binding parameter called treeState. To me, this seems to be a possible solution for not losing the expanded / collapsed state of the nodes after saving changes.
The problem that I have is that the documentation is vague and I can't find any examples of how this parameter could be used.
The following are unclear to me:
Thank you and have a good day!
SePo
Hi,
Before the refresh, we do that :
this._oTreeState = this._oTable.getBinding("rows").getCurrentTreeState();
this._oTable.getBinding("rows").setTreeState(this._oTreeState);
this.getModel().refresh();
Regards
Fabrice
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fabrice,
Thank you for you quick answer!
What version of SAPUI5 are you using? I'm asking because I tried the same thing but "getCurrentTreeState" is not found on the binding object.
Also, are you providing a treeState via binding parameters when you initialize the TreeTable binding?
Thank you!
SePo
Hi,
We use version 1.52
the binding is like that :
this._otable.bindRows({
path : <our_path>,
parameters : {
countMode: "Inline",
operationMode:sap.ui.model.odata.OperationMode.Client,
numberOfExpandedLevels: iNumberOfExpandedLevels,
treeAnnotationProperties : {
hierarchyLevelFor : iHierarchyLevelFor ,
hierarchyNodeFor : sHierarchyNodeFor ,
hierarchyParentNodeFor : sHierarchyParentNodeFor ,
hierarchyDrillStateFor : sHierarchyDrillStateFor
}
}
});
Regards
Fabrice
Hmm... this gets even stranger :-).
I too am using 1.52 and the binding is similar (except treeAnnotationProperties; I'm using the annotations on the metadata level).
Thanks for your help Fabrice... I guess I have to look deeper into the SAPUI5 code and see why the ODataTreeBindingAdapter doesn't add these methods (getCurrentTreeState and setTreeState) to the ODataTreeBinding of my table.
Hi Fabrice,
I figure out what happens... the TreeTable that I expected to have this method is inside a SmartTable. It seems that the bindings of TreeTables inside SmartTables don't get this method as long as enableAutoBinding = true.
Thanks!
Have a good day!
SePo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
11 | |
10 | |
8 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.