cancel
Showing results for 
Search instead for 
Did you mean: 

Expand SAPUI5 TreeTable after saving

former_member569797
Discoverer

Hi everyone,

with an editable sap.ui.table.TreeTable when user saves changes, data are refreshed using a GET request to backend and table is re-rendered. Unfortunately, expanded nodes of table are not saved and user has to expand manually again.

Exemple:

We use "Apply to selection" button to save changes made on this tree table. We can see that first and second row are expanded before we click save button.

When save is done, table is refreshed and is not expanded anymore.

I know I can expand to a predetermined level by default, but what I want is to keep the same expanded state that user has before save.

We already tried to save expanded nodes ids and expand these nodes in "onAfterRendering" event of the tree table, but this event is fired too early: table is not completely generated and treeTable.expand() method doesn't work.

Any help would be appreciated 🙂

Regards

0 Kudos

Hi,

I have the same problem as you described.

I think about adding a property in the entity which contains information on whether the node is expanded or not and forward it to the database at the backend when I save the entity so that I can read it out in the refreshing process. But I think it seems to be a bit complicated to have an extra field in my database for saving this information but at the moment I have no better idea.

How did you solve the problem? Did you find a good solution?

Best regards!

0 Kudos

Hi,

We have a similar issue, once the data is refreshed we lose the tree start.

Please let us know how could we solve it.

thanks and regards,

sharath

ThorstenHoefer
Active Contributor
0 Kudos

Hi,

I'm facing the same issue.
My Idea is to store the expanded nodes.

      var _oTreeTable = this.getView().byId("xyz");
      _oTreeTable.getRows(function(pRow,pIndex){
        if(_oTreeTable.isExpanded(pIndex))this.aExpandNodes.push({row: pRow, idx : pIndex});
      });

But the Problem is to find the event after the tree table is rebound. Then I would call following function:

    onRowsUpdated: function(oEvent){
      debugger;
      var _oTreeTable = this.getView().byId("xyz");
      this.aExpandNodes.forEach(function(pRow){
        _oTreeTable.expand(pRow.idx);
      });
      this.aExpandNodes = [];
    },

Any Ideas are highly appreciated.

Greetings

Accepted Solutions (0)

Answers (0)