英文:
Vaadin 23 align components in Grid header for filtering
问题
这是我用于Grid筛选组件的代码:
headerRow.getCell(idColumn).setComponent(FilterUtils.createIdFilterHeader(dataViewFilter::setId, "user.id"));
headerRow.getCell(nameColumn).setComponent(FilterUtils.createNameFilterHeader(dataViewFilter::setName, "user.first.name"));
VerticalLayout referrerFilterVerticalLayout = new VerticalLayout();
referrerFilterVerticalLayout.setMargin(false);
referrerFilterVerticalLayout.setPadding(false);
referrerFilterVerticalLayout.setSpacing(false);
referrerFilterVerticalLayout.add(FilterUtils.createIdFilterHeader(dataViewFilter::setReferrerId, "referrer.id"));
referrerFilterVerticalLayout.add(FilterUtils.createNameFilterHeader(dataViewFilter::setReferrerName, "referrer.first.name"));
headerRow.getCell(referredByColumn).setComponent(referrerFilterVerticalLayout);
现在的表头如下所示:
我需要调整前两个组件的位置,使它们上移以获得如下所示的效果:
请展示如何实现这个效果。
英文:
This is the code I have for Grid filtering components:
headerRow.getCell(idColumn).setComponent(FilterUtils.createIdFilterHeader(dataViewFilter::setId, "user.id"));
headerRow.getCell(nameColumn).setComponent(FilterUtils.createNameFilterHeader(dataViewFilter::setName, "user.first.name"));
VerticalLayout referrerFilterVerticalLayout = new VerticalLayout();
referrerFilterVerticalLayout.setMargin(false);
referrerFilterVerticalLayout.setPadding(false);
referrerFilterVerticalLayout.setSpacing(false);
referrerFilterVerticalLayout.add(FilterUtils.createIdFilterHeader(dataViewFilter::setReferrerId, "referrer.id"));
referrerFilterVerticalLayout.add(FilterUtils.createNameFilterHeader(dataViewFilter::setReferrerName, "referrer.first.name"));
headerRow.getCell(referredByColumn).setComponent(referrerFilterVerticalLayout);
Right now the header looks like:
I need to adjust the first two components and move them up to get something like this:
Please show how to achieve this.
答案1
得分: 0
可能最简单的方法是将您的筛选框放在两个水平布局中,放在垂直布局内。
英文:
Probably the easiest thing would be to stick your filter boxes in two Horizontal Layouts, within the Vertical Layout.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论