本文整理汇总了Java中com.vaadin.ui.Grid.Column.setHidable方法的典型用法代码示例。如果您正苦于以下问题:Java Column.setHidable方法的具体用法?Java Column.setHidable怎么用?Java Column.setHidable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vaadin.ui.Grid.Column
的用法示例。
在下文中一共展示了Column.setHidable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupGridPropertyColumn
import com.vaadin.ui.Grid.Column; //导入方法依赖的package包/类
/**
* Setup column configuration for given <code>property</code> using its {@link PropertyColumn} definition.
* @param property Property to which the column is bound
* @param column Column to setup
*/
protected void setupGridPropertyColumn(P property, Column column) {
PropertyColumn<T, P> propertyColumn = getPropertyColumn(property);
if (propertyColumn != null) {
// header
if (propertyColumn.getCaption() != null) {
String header = LocalizationContext.translate(propertyColumn.getCaption(), true);
if (header != null) {
column.setHeaderCaption(header);
}
}
// sortable
column.setSortable(requireDataSource().getConfiguration().isPropertySortable(property));
// width
if (propertyColumn.getWidth() > -1) {
column.setWidth(propertyColumn.getWidth());
}
if (propertyColumn.getMinWidth() > -1) {
column.setMinimumWidth(propertyColumn.getMinWidth());
}
if (propertyColumn.getMaxWidth() > -1) {
column.setMaximumWidth(propertyColumn.getMinWidth());
}
// expand
if (propertyColumn.getGridExpandRatio() > -1) {
column.setExpandRatio(propertyColumn.getGridExpandRatio());
}
// editing
if (requireDataSource().getConfiguration().isPropertyReadOnly(property)) {
column.setEditable(false);
} else {
column.setEditable(propertyColumn.isEditable());
if (propertyColumn.isEditable()) {
propertyColumn.getEditor().ifPresent(e -> column.setEditorField(e));
}
}
// hiding
if (columnHidingAllowed && propertyColumn.isHidable()) {
column.setHidable(true);
if (propertyColumn.isHidden()) {
column.setHidden(true);
}
if (propertyColumn.getHidingToggleCaption() != null) {
column.setHidingToggleCaption(
LocalizationContext.translate(propertyColumn.getHidingToggleCaption()));
}
} else {
column.setHidable(false);
}
}
}
示例2: DemoContentLayout
import com.vaadin.ui.Grid.Column; //导入方法依赖的package包/类
public DemoContentLayout() {
final SelectGrid<TestObject> grid = new SelectGrid<>();
grid.addColumn(TestObject::getFoo).setCaption("Foo");
grid.addColumn(TestObject::getBar, new NumberRenderer()).setCaption("Bar");
grid.addColumn(TestObject::getKm, new NumberRenderer()).setCaption("KM");
grid.setHeightByRows(10);
grid.setHeightMode(HeightMode.ROW);
// Show it in the middle of the screen
setStyleName("demoContentLayout");
setSizeFull();
addComponent(grid);
setComponentAlignment(grid, Alignment.MIDDLE_CENTER);
final TableSelectionModel<TestObject> tableSelect = new TableSelectionModel<>();
grid.setSelectionModel(tableSelect);
tableSelect.setMode(TableSelectionMode.CTRL);
HorizontalLayout tableSelectionControls = new HorizontalLayout();
tableSelectionControls.setCaption("Table Selection Controls");
// Controls for testing different TableSelectionModes
for (final TableSelectionMode t : TableSelectionMode.values()) {
tableSelectionControls.addComponent(new Button(t.toString(), e -> tableSelect.setMode(t)));
}
addComponent(tableSelectionControls);
// TODO: PagingDataProvider
PagedDataProvider<TestObject, SerializablePredicate<TestObject>> dataProvider = new PagedDataProvider<>(
DataProvider.ofCollection(TestObject.generateTestData(995)));
grid.setDataProvider(dataProvider);
PagingControls pagingControls = dataProvider.getPagingControls();
HorizontalLayout pages = new HorizontalLayout();
pages.setCaption("Paging controls");
pages.addComponent(new Button("First", e -> pagingControls.setPageNumber(0)));
pages.addComponent(new Button("Previous", e -> pagingControls.previousPage()));
pages.addComponent(new Button("Next", e -> pagingControls.nextPage()));
pages.addComponent(new Button("Last", e -> pagingControls.setPageNumber(pagingControls.getPageCount() - 1)));
VerticalLayout controls = new VerticalLayout();
controls.addComponents(tableSelectionControls, pages);
controls.setWidth("100%");
controls.setHeightUndefined();
controls.setComponentAlignment(tableSelectionControls, Alignment.MIDDLE_CENTER);
controls.setComponentAlignment(pages, Alignment.BOTTOM_CENTER);
addComponent(controls);
setComponentAlignment(controls, Alignment.MIDDLE_CENTER);
grid.getEditor().setEnabled(true);
for (Column<TestObject, ?> c : grid.getColumns()) {
c.setHidable(true);
}
}