how to know which button was clicked in reactive
Application Type
Reactive

Hi,

I want to show data in a block (used inside a sidebar) based on which button was clicked.

I have around 8 buttons, that opens up a sidebar on click and shows data related to which button was clicked. I'm able to open up a sidebar, used if condition to show data based on True or False condition (as of now). But I want to change the the condition to check which button was clicked (maybe check with id) and then show respective data.

Image below :
you can see a sidebar on left, buttons on the chart - have 1 button below every chart ( 8 charts - 8 buttons ).

Image of block used :
condition is set to True - as I don't know how to find which button was clicked.

I tried to do like below but it didn't work.

Hi,

i hope i did get your question right. What you can do is that you add an input parameter to the client actions which handles the OnClick event handler of every button you (so multiple buttons, single click handler).

The input parameter could be "ButtonPressed" with values like "ChartLeftMoreClicked" (you can also create a static entity for that).

In the client action you assign the value of ButtonPressed to a local variable within your screen.

You add an input parameter to your block, add the block to the sidebar in your screen and assign the local variable containing the button pressed value to the blocks input parameter.

You add the OnParametersChanged event handler to your block to define what happens when the input parameter changes (eg. refreshing the datasources).

You use the input parameter as a condition on various conditional statements eg "CurrentButton" = "ChartLeftMoreClicked".

Best

Stefan

Hi,

Thank you for the help. I cannot figure out this line "The input parameter could be "ButtonPressed" with values like "ChartLeftMoreClicked" (you can also create a static entity for that).". Do I need to create 8 input parameters with specific values for them? 


Also, i can't find a way to assign the local variable value containing the button pressed value to the blocks input parameter. it gives me "undefined element" error. 

If you can, an OML would be really helpful. 

Thanks,

Aman

Hey,

You can use call event on button click inside block that will send button name to parent screen  and based on that button name you can apply conditions.

Hope you will understand.

Thanks

Yogesh J

Here you go. This OML uses a static entity for the button actions. Each button targets the ActionButtonClicked client action which takes a single input of ButtonActionId. This parameter is then assigned to a local variable which is used as input parameter to the Block.

The block has a client action OnActionSelected which perfoms a switch assigning text to a local variable.

That client action is added to the OnInitialize (First run) and OnParametersChanged (subsequent changes) event of the block.

Hope that helps.

Stefan

MultiButton.oml

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.