vaadin / vaadin/framework

can one right align components in a HorizontalLayout component cell of a TreeGrid component column?

Open
#12,319 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement workaround
Dominant language
Java
Stars
1.8k
Forks
717
Avg merge
2d 6h
Merged PRs (30d)
3

Description

Hello! First of all thank you for your work.

  • Vaadin Framework version - 8.12.3
  • Browser version - chrome 90.0.4430.212
  • Description of the bug
    I have a TreeGrid with 2 component columns. The first component column contains a HorizontalLayout with a Label and a Button. The second component column contains a HorizontalLayout with a Button. I was not able to right align the Button in the first component column. Is it doable?
    vaadingithub

Thank you!

  • Minimal reproducible example
TreeGrid<Object> treeGrid = new TreeGrid<>();
treeGrid.setSizeFull();
treeGrid.addComponentColumn(vp -> {
    Button button = new Button("button");
    HorizontalLayout cell = new HorizontalLayout(new Label("label"), button);
    cell.setSizeFull();
    cell.setExpandRatio(button, 1.0f);
    cell.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);
    return cell;
}).setCaption("st column").setExpandRatio(1).setId("st column");
treeGrid.addComponentColumn(vp -> new HorizontalLayout(new Button("some other button")))
        .setCaption("nd column").setId("nd column").setWidth(200.0d);
TreeData<Object> objectTreeData = new TreeData<>();
objectTreeData.addRootItems(new Object());
treeGrid.setDataProvider(new TreeDataProvider<>(objectTreeData));
window.setContent(treeGrid);
UI.getCurrent().addWindow(window);
window.center();
window.setWidth("40%");
window.setHeight("40%");```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal reproducible example in the issue and inspect how TreeGrid component columns size HorizontalLayout cells and apply component alignment. Verify the behavior with the first component column containing a Label and Button; done when the Button is visibly right-aligned within that cell.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.