com.vaadin.ui.Grid.setColumns()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中com.vaadin.ui.Grid.setColumns()方法的一些代码示例,展示了Grid.setColumns()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Grid.setColumns()方法的具体详情如下:
包路径:com.vaadin.ui.Grid
类名称:Grid
方法名:setColumns

Grid.setColumns介绍

[英]Sets the columns and their order based on their column ids. Columns currently in this grid that are not present in the list of column ids are removed. This includes any column that has no id. Similarly, any new column in columns will be added to this grid. New columns can only be added for a Grid created using Grid#Grid(Class) or #withPropertySet(PropertySet).
[中]根据列ID设置列及其顺序。此网格中当前不在列ID列表中的列将被删除。这包括任何没有id的列。类似地,列中的任何新列都将添加到此网格。只能为使用网格#网格(类)或#withPropertySet(PropertySet)创建的Grid添加新列。

代码示例

代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin

/**
 * Set given properties as listing visibile columns.
 * @param columns Visible columns properties (not null)
 */
protected void setupVisibileColumns(Iterable<? extends P> columns) {
  final List<? extends P> columnsList = ConversionUtils.iterableAsList(columns);
  final List<? extends P> visibleColumns = (columnsList != null && !columnsList.isEmpty()) ? columnsList
      : getDefaultVisibleProperties().orElse(Collections.emptyList());
  if (!visibleColumns.isEmpty()) {
    List<String> ids = new LinkedList<>();
    visibleColumns.forEach(property -> {
      setupVisibleColumn(property);
      final String columnId = getColumnId(property);
      setupPropertyColumn(property, getGrid().getColumn(columnId));
      ids.add(getColumnId(property));
    });
    getGrid().setColumns(ids.toArray(new String[ids.size()]));
  }
}

代码示例来源:origin: stackoverflow.com

public class MyUi extends UI {
  @Override
  protected void init(VaadinRequest request) {
    // basic stuff
    Layout content = new VerticalLayout();
    content.setSizeFull();
    setContent(content);

    // container & grid
    BeanItemContainer<Address> container = new BeanItemContainer<>(Address.class);
    Grid grid = new Grid(container);

    // 1) either manually add nested properties and hide the actual inner bean
    container.addNestedContainerProperty("city.name");
    grid.getColumn("city.name").setHeaderCaption("City");
    grid.setColumns("street", "city.name"); // hide bean column

    // 2) or make the container create nested properties for your inner beans
    container.addNestedContainerBean("city");
    grid.getColumn("city.name").setHeaderCaption("City");

    // create some dummy data to populate the grid
    City city = new City("There");
    Address address = new Address(city, "Here");
    container.addItem(address);
    content.addComponent(grid);
  }
}

代码示例来源:origin: com.holon-platform.vaadin7/holon-vaadin

final Grid grid = getGrid();
grid.setColumns(columnsArray);

相关文章

Grid类方法