GridLayout - problems getting rows or components

Hi, I am having some trouble with programmatic hiding/showing rows (or the components in the rows) in a GridLayout Component.

Currently, my Grid has 2x rows. the first row has a Label and an OptionsGroup and the second row has a Label and a LookupPickerField. The Grid, Row and Components each have a unique ID.

My goal is to be able to programmtically hide/show the components in the SECOND row based on some criteria. However

  • I cannot find a Row component Object to Inject Rows into the Controller, so I assume Rows are not a Component regardless of having an ID
  • If I trying Injecting the components from the second row independently, they are not identified (using either @Inject or @Named with different name variants, i.e. dot notating grid/row name or not)
  • Getting the Collection of the Grid only returns 2x Components - these are the components in the first row, not the second

Any help would be greatly appreciated

Hi Gary,

First of all, rows are only simple abstraction of design time and ids of rows are only used by screen extension mechanism. So, you cannot inject rows as components.

All child components with ids can be easily injected and if you have a trouble with them please share example screen XML descriptor and Java controller.

Also getComponents/getOwnComponents calls should return you (all nested)/(only children) components without any problems.

You can only hide all row/column if you hide all components of this row/columns. I’ve attached sample project and there you can see example of hiding rows/columns of Grid layout.

And what version of CUBA do you use? (21.4K)

Hi Yuriy, thanks for this.
I currently use 6.2.0 (I havent applied 6.2.1 yet)
I have attached the screen xml I am working with currently.
In the controller, I am (trying) to inject as follows (the commented out is where I was trying different things)

//    @Named("labelSelectUser")
//    private Label labelSelectUser;
//    @Named("lookupUserSelection")
//    private LookupPickerField lookupUserSelection;
    private Label labelSelectUser;
    private LookupPickerField lookupUserSelection;

Both variants of this return null for the components :frowning:
I havnt had a chance to look at your sample as yet - so maybe it is something really idiotic I am doing (1.3K)

Hi, you are right, in your case injection does not work.

You’ve used visible attribute of row and it seems that this attribute has obsolete logic of initialization, it does not initialize child components if visible=false. We are planning to deprecate it in the next version of CUBA.

Please hide/show your components programmatically using setVisible method and this case will work properly.