280
Views
10
Comments
Is there any way of load/unload different blocks on same screen.?
Application Type
Reactive
Service Studio Version
11.54.4 (Build 62290)

Hi, 

I have a layout like this...

I have multiple blocks (one of them is you can see client restriction). I want to implement something like I can load/unload different blocks on the same screen on some client action from left pane or menu bar.

Please don't suggest visibility option. As I don't want that implementation

2018-06-05 16-54-03
Maria da Graça Peixoto

Hi! 

You can do it in different way being one of them this : 

Add to the place where you want to display the webblocks a serie of "If's" each one inside the presious, like  

If  <Condition to Block1>

 True  (show Block1)

 False If <Condition to Block 2>

              True  (show Block2) 

              False If ...

Every time the the conditions change the corresponding block will be showed. In this case only one of the blocks is shown at a time.

The if's are directly in the UI and don't use  the Visibility property. 

Regards

Graça

UserImage.jpg
Keshav Raghav

But the blocks are loaded at the backend. I have 70 blocks like this,  I cant play on visibility.

2021-09-06 15-09-53
Dorine Boudry
 
MVP

what exactly do you mean when you say "loaded at the backend"

the blocks don't become part of the dom and don't get initialized as long as they are either visible false or inside an if that is not true. And aggregates are also not executed until they become visible.

So where do you see the problem with using visibility ?

2021-04-09 12-35-11
Tiago Babo

Hi!


A possible way to do that is using multiple "if" widgets where you have each block in each of those ifs:

if (some condition)

     True: X Webblock

     False: if (some other condition)

                     (.....)

You just have to set up the conditions to decide which webblock to show on the screen at any time. You can use multiple boolean local variables, or whichever way makes sense for your use case.


Best regards,

Tiago Babo

2018-06-05 16-54-03
Maria da Graça Peixoto

How many blocks must be shown at the same time? 

70 if's is a lot but in run time , with mine or Tiago Babo's solution only one is showed. So I don't understand what you mean by " I cant play on visibility ". 

If you must have more then one at the same time you must separate those If's from the chain and  have a some thing like 

If  <Condition to Block1> 

   True  (show Block1)

    False If <Condition to Block2> 

                  True  (show Block2) 

                  False < Show Block3 >

If <Condition to Block4> 

   True  (show Block4)

    False <Empty> 


This will show Block1 or Block2 or Block3   and  Block4 if <Condition to Block4>  is true


The if's are directly in the UI and don't use  the Visibility property. 

2018-06-05 16-54-03
Maria da Graça Peixoto

About your problem , 

I have done similar things in other kind of platforms, and we end up by creating some generic blocks that  update different fields and entities according to the value of a parameter. That way we succeeded in reducing the number of different blocks in use. 

Hope this help you

Graça

2021-04-09 12-35-11
Tiago Babo

If you don't fancy using that many if widgets, you can also just encapsulate each webblock in it's own container and change the "Visible" property of those containers. This will allow you to have multiple webblocks showing at the same time, if that's something you want.

This is usually the way I prefer to do it, since it makes the widget tree a bit cleaner during development. But either way should work just fine.

If you wish to streamline you code a bit more and use less webblocks, then you should follow Maria's solution.

Regards

Tiago Babo

2022-07-03 17-24-08
Sourabh sharma

Hi @Keshav Raghav 

@Dorine Boudry is super correct!!  instead of  70's IF you must use the visibility  property .

but still if you want to use "IF" then i can give you an idea to make master blocks according to your conditions and in those master blocks keep those blocks which are having same condition to show or appear.

and those master blocks consume in mail screen the keep them in IF condition .

hope this can work for you !!!

kind regards 

Sourabh Sharma

2023-05-30 19-50-24
Fernando Ferreira

You can use this solution as stated above or encapsulate it in containers and place conditions on the visibility, which becomes much clearer to understand when looking at the Widget Tree If(Condition A,True,if(Condition B, True,if(Condition C , True,if,(Condition D, True, False ))))

2025-02-10 17-24-13
Arun Rajput

Hi @Keshav Raghav 

Visibility or If is correct solution as said above but still if you don't want to do that then you need to create dynamic block/Form.

I mean block will be only one but fileds will fetch from database according to menubar.

There are lots of dynamic form component on forge you can use any one from them.

Thanks

Arun 

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