cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying/hiding smart tables based off data does not work.

former_member595374
Participant
0 Kudos

Hello, in my XML I have two smarttables. Only one smarttable is supposed to be visible at a time. I toggle the visibility by setting visible to whether the data I am getting from the backend is true or false. To make things easier though, let's just say I am setting visible to true for one table and false for another table.

When I set visible to false for the first table and true for the second table, the second table displays. When I set visible to true for the first table and false for the second table, no table displays. It seems my project completely ignores the first table and just goes to the second table to see if the visibility is on for that one. Why is this happening and how do I fix this?

My XML is something like this:

<smartTable:SmartTable 
id="firstTable"
demandPopin="true"
enableAutoBinding="true"
entitySet="Flowers"
visible="true">
</smartTable:SmartTable>

<smartTable:SmartTable 
id="secondTable"
demandPopin="true"
enableAutoBinding="true"
entitySet="Flowers"
visible="false">
</smartTable:SmartTable>

My controller code is like this:

if (this.getView().byId("firstTable").getVisible()){
this.flowersSmartTable = this.getView().byId("firstTable");
}
else {
this.flowersSmartTable = this.getView().byId("secondTable");
}

Accepted Solutions (0)

Answers (3)

Answers (3)

Joseph_BERTHE
Active Contributor
0 Kudos

Hello,

Why the second table has the same entity set?

Regards,

Joseph

former_member595374
Participant
0 Kudos

Is that where i'm going wrong? I have it as the same entity set because it is the same table essentially. I just wanted to duplicate the first table but have certain fields ignored via ignoreFromPersonalisation.

<smartTable:SmartTable 
id="secondTable"
demandPopin="true"
enableAutoBinding="true"
entitySet="Flowers"
visible="false"
ignoreFromPersonalisation="daisies,roses,sunflowers">

I wrote the first and second table to display the same exact things minus the fields in ignoreFromPersonalisation.

Joseph_BERTHE
Active Contributor
0 Kudos

I don't know if it is the problem, but when I see two identic table I warn it 🙂

If you want to manipulate the column visibility dynamically througth a SmartTable it is completly possible without ignoreFromPersonalisation.

Look at my blog : https://blogs.sap.com/2019/08/08/all-you-need-to-know-about-smartfields/

Regards,

Joseph

junwu
Active Contributor
0 Kudos

did you try ui5 inspector?

former_member595374
Participant
0 Kudos

Yes, i've tried it. I didn't find anything useful with it.

I have never used this tool before though so maybe i'm not using it efficently.

junwu
Active Contributor
0 Kudos

just switch to ui5 tab in developer tool.

check if you can find the two table, inspector will tell you the visibility

junwu
Active Contributor
0 Kudos

for the visible smarttable, you can right click and choose "inspect ui5 control", then check if you can find another table around.

former_member595374
Participant
0 Kudos

Ah yes, only one table shows up in "inspect ui5 control"...the second table.

junwu
Active Contributor
0 Kudos

where is the code to set the visibility?

former_member595374
Participant
0 Kudos

It's in the XML.

visible="true" 
junwu
Active Contributor
0 Kudos

hardcoded?

former_member595374
Participant
0 Kudos

Hardcoded for now just to make debugging easier. When I hardcode visibility of first table to "true" and second table to "false", nothing gets displayed even though I think the first table should get displayed in this situation.

junwu
Active Contributor
0 Kudos

use ui5 inspector to check what is happening in the browser.

former_member595374
Participant
0 Kudos

The browser is showing me that only the secondTable is present.