For example if I have form with 2 columns and 2 rows but want to keep the 2nd column in the first 1st empty how do I do this without adding an empty value (empty Span).
-----------------
| field | empty |
-----------------
| field | field |
-----------------
Right now I'm doing:
formLayout.add(new TextField("First row and first column"));
formLayout.add(new Span());
formLayout.add(...);
.. and so on.
I could just do formLayout.add(textField, new Span(), textField, ...) but in either case my question is how can I have the FormLayout skip a cell in the first row after the initial TextField?
FormLayout is not purposed to be rigid grid. You can add empty components, or Br component to break a row, which will work better than empty Span.
You can also adjust col-span of FormItem to span it wider than a column. But FormLayout is also responsive, so if you make Browser narrower, it will reflow the fields. Empty components would make it look odd as there are not likely to be place as you want.
You can also set responsive steps to control whether four, three, two, .. columns are shown on different Browser widths:
formLayout.setResponsiveSteps(
new ResponsiveStep("25em", 1),
new ResponsiveStep("32em", 2),
new ResponsiveStep("40em", 3));
In theory you can adjust the responsive steps so that layout is more rigid.
I would assume that a Div component where you set css-grid styles according to what you want to achieve may server you better than FormLayout in this case.
Related
I would like to use FormLayout where one of the fields is visible depending on another field. Is there a way to keep the formatting the same, that is for all the fields after it to stay in their same position when another component is invisible.
Below is the code to reproduce as well as a screenshots of what I would like compared to the current behavior. In essence each time you select the combobox you make the "Year Joined Team" field invisible/visible.
TextField nameTextField = new TextField("Name");
ComboBox<String> teamComboBox = new ComboBox<>("Team");
DatePicker yearJoinedDatePicker = new DatePicker("Year Joined Team");
TextField moreFieldsTextFields = new TextField("More fields");
FormLayout formLayout = new FormLayout();
formLayout.setWidth("600px");
formLayout.setResponsiveSteps(new FormLayout.ResponsiveStep("0", 2, FormLayout.ResponsiveStep.LabelsPosition.TOP));
formLayout.add(nameTextField,
teamComboBox, yearJoinedDatePicker,
moreFieldsTextFields);
teamComboBox.setItems(List.of("One", "Two"));
teamComboBox.addValueChangeListener(change -> yearJoinedDatePicker.setVisible(!yearJoinedDatePicker.isVisible()));
formLayout.setColspan(nameTextField, 2);
add(formLayout);
Ideally the goal is to have the fields below the yearJoinedTeamDatePicker component to stay below so that all other components below continue to be aligned correctly when it's set to be invisible.
Instead what actually happens is that all the components are shifted on field to the left, as if the invisible component is no longer part of the FormLayout. Meaning the moreFieldsTextField is now on a different row, and if everything is setup for two columns every row will be incorrect. I understand that this makes sense in some context but in a FormLayout is there a way to keep the form formatted if a component is invisible?
If for example I had firstname and lastname as two side by side fields they would now be on different rows as shown below:
A very hacky solution would be to add in a Span component or something like that and make it invisible when the yearJoinedDatePicker field is visible, and invisible when it's visible. Basically fill it in with an empty field when it's invisible. That is a hacky workaround but it doesn't seem like an appropriate solution. With that in mind is there a way to keep the formatting/layout if a component is invisible?
What you are trying to achieve is sort of defying the purpose of FormLayout. FormLayout has css flex rules to wrap elements / components by row. Thus if you switch visibility of a component, the behavior is as you described.
One thing you could do, is to wrap "Team" and "Year joined team" inside e.g. HorizontalLayout and set
formLayout.setColspan(horizontalLayout, 2);
See, also my previous answer about FormLayout https://stackoverflow.com/a/69270190/8962195
If you want to keep the place, maybe it's vable for you to set the field ti disabled with setEnabled.
I'm not sure how it would behave, but you could try CSS display: none instead of the setVisibility(false).
i have a table. to print like this
https://up.djelfa.info/uploads/155762484493151.png
I want to make the observation take the whole table means it remains empty. The empty box takes all the table.
https://up.djelfa.info/uploads/155762492124361.png
im working with fastreport 5 vcl
master data
https://up.djelfa.info/uploads/155762509600791.png
Per your last link, it appears that you have hard-drawn the cell lines in your master data row. This means they will print for each row. There are, however, multiple ways to get around this:
Make the upper and lower lines for your Observation column separate objects (e.g. LineObsTop and LineObsBottom). Then, in the MasterData Band's OnBeforePrint, adjust the visibility of these based on the values of the column
Don't hard-code cell lines! Instead, make sure the cell fields all align perfectly and use the fields' Frame properties. Then use the Observation field's OnBeforePrint to adjust the frame based on value.
Similar to #2, but use conditional formatting for the cell, adjusting the frame.
I have a ui grid that has 20 columns, and I would like to be able to tell what the next column will be as I scroll through the horizontal axis so that I can have some text that will tell the users what the names of all the columns they can't see are.
Anyone know if this is possible? As I watch the the inspector and scroll through the columns, I see html attributes changing.
---UPDATE 1----
This is what is all looks like (where it says "home #" is dynamic and will change to show the next column that is out of site)
Based on the ui-grid configuration that you use to render the grid, you already know the order of the columns. You can use this information together with the visible on each column added by the gird itself.
What you need to do is bind a event handler on scroll to iterate over the columns on each change and check the visibility of them. Then the first one with visible === false is the upcoming.
Here is a working Plunker where is used this flag.
There is a computed field Native OS Style, width-fixed: 0.409'', height - Proportional.
When its form is composed, it has a default value let say 3.
I get something like this: where ( ____ is the "length" of the field )
3
___
Is there any chance to make it like this ?
3
___
I read that I need to get to the Text properties ( second tab ) because the field will follow that allignment, but I didn't know how, considering the fact that the field position is ok, I just want to change the value alignment.
Thanks for your time!
It sounds like you're asking about a Notes client app (not a web app).
A "native OS style" field has the text on the left. That's just how these fields work. To get the effect you're looking for, I think you would have to create a "fake" native-style field. Use a table with borders only on the cell containing the field, and in the cell put a Notes-style field but uncheck the option to display field delimiters. Now, if you right-align the cell contents, that will affect the text typed into the field.
If you don't like tables, a "layer" should also work.
I've got an interesting problem that I'd like some advice and opinions on if you would be so kind. I'm not after code as I prefer to write that for myself. My background is J2ME and Android but I've recently taken up Blackberry.
What I need to write is something akin to the Android ListView albeit a little simpler.
Each row consists of 3 items. There's an image/icon, a multi-line (2 or 3 row) text element and an imagebutton of some form.
However, each row has only 2 columns. The icon/image & multi-line text are combined for the first column and are clickable (with both the column (0) plus the row ID identifiable). The next element in the row (1) is a clickable image (common to all rows - this also needs to have an identifiable row ID). There must be different actions for each column/row cell.
There is a need for multiple rows to be scrollable vertically and there may well be a lot of items.Each row needs to fit the screen width with the icon/multi-line text justified to the left and the clickable image justified to the right. Each row needs all of its components vertically justified (possibly centred) for neatness.
So what we have (for a row) is:
[clickable image/multi-line text combo][clickable image]
Ideally there will be a common background (gradient shaded) for each row once focussed. This should span both columns seamlessly.
Any thoughts would be most appreciated.
The simplest approach is probably to have a VerticalFieldManager for the list, populated by HorizontalFieldManagers for the row.
As for the inner part of the row (the columns) you can pass FIELD_LEFT to the first field and FIELD_RIGHT for the second for alignment. The image-multitext field you can create yourself by extending ButtonField and overriding the paint method. You can use the Graphics object to draw your image and text. A different approach (and perhaps a simpler one) is to extend the HorizontalFieldManager, add your components and make it clickable by capturing the click events.
One thing to realize about Blackberry is that there are many ways to do something, if one thing doesn't work quite the way you want it to, try something different. Hope this help you get started!