cancel
Showing results for 
Search instead for 
Did you mean: 

Create Dynamic Buttons in Sap Design Studio

sinaei
Contributor
0 Kudos

Hello Experts,

In our scenario we have 6 buttons that based on some condition, some of them should be visible.

For example, in some cases we need to see just first and third button but the position should not be fix.
Can anyone help me how can we create or handle dynamic scanerio in sap design studio?

Thanks
Sepide

former_member421500
Discoverer
0 Kudos

Did you try using TEXT elements with {display:inline-block} inside a PANEL, which width is set to auto?

In this case if you hide an element, its' siblings will rearrange automatically.

Accepted Solutions (1)

Accepted Solutions (1)

nikhil_joy2
Active Contributor
0 Kudos

Hello Sepide,

It is possible with text boxes as buttons and dynamically hiding and showing based on your logic. Text in each button and corresponding action can be adjusted with SetText() so in your example, Text box in position 2 can have text of position 3 and text boxes of position 3 and 4 can be hidden.

Regards,

Nikhil Joy

sinaei
Contributor
0 Kudos

Hi Nikhil,

Thanks for your reply,

I am not sure if I got your point.

You mean instead of Button, I need to inser Text Components (in my case 4 Text)

and then

if case 1{
   Text1.setText() = "MyText";
   Text2.setText()= "MyseconText"
   ...
}

I did not understand the advantage of TextComponents instead of Button in this case. since also whith Button I can set the text manually.

And also what about the logics of each text?

In every TextComponent I need to say:

If this.getSeelectedText== "MyText"{
   do Related action
)
else if this.getSelectedText== "MyText2"{
   Do another action
}

You mean this?

This is not dynamic from my point of view.

Thanks
Sepide

nikhil_joy2
Active Contributor

Hi Sepide,

I prefer text box over buttons in these scenarios because of its flexibility to apply CSS. You are right, you can do it with buttons.

If you selectively hide unwanted buttons and exchange the text in it to near by buttons, it is not dynamic from a user perspective ?

I don't know what is your conditions. but as an example, if you want button1 and button3 visible in one case, you don't need a blank space of button2 in between, instead you want to see button3 in the place of button2 and hide remaining 2 last buttons. this is my understanding about your requirement. In this case if you dynamically assign text of button3 to button2 and hide buttons in position 3 and 4, it works dynamic in my opinion. as you mentioned already, based on getSelectedText() you can control the action also dynamically.

If you do not have many such conditions, you can try dynamically hiding and showing multiple sets of buttons in different panels too.

Correct me if my understanding is wrong.

Regards,

Nikhil Joy

sinaei
Contributor
0 Kudos

Hi Nikhil,

Yes Exactly that is my requirement! your suggestion gave me an idea!

I used "ComponentManager" and get all my Buttons and then based on my condition as you suggest I used SetText of each button dynamically.

I do not find any other solution better than this.

Thanks for your help

Sepide

Answers (1)

Answers (1)

TammyPowlas
Active Contributor
0 Kudos

If you update to Lumira 2.x you could consider using dynamic components, blogged here by David Stocker: https://blogs.sap.com/2017/12/18/dynamic-components/

sinaei
Contributor
0 Kudos

Thanks Tommy,
Yes I saw this but we can not update right now to Lumira