Table 列 headers 未显示在 Wicket 的 Table 树中
Table column headers are not displaying in TableTree in Wicket
private void myTreePage() {
private final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("<root>");
DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
statusImport();
ITreeProvider<DefaultMutableTreeNode> modelProvider = new TreeModelProvider<DefaultMutableTreeNode>(treeModel, false) {
private static final long serialVersionUID = 1L;
@Override
public IModel<DefaultMutableTreeNode> model(DefaultMutableTreeNode object) {
return Model.of(object);
}
};
TableTree<DefaultMutableTreeNode, String> myTestTree = new TableTree<DefaultMutableTreeNode, String>("myTestTreeTable", createColumns(), modelProvider, Long.MAX_VALUE) {
private static final long serialVersionUID = 1L;
@Override
protected Component newContentComponent(String id, IModel<DefaultMutableTreeNode> model) {
//return new CheckedFolder<DefaultMutableTreeNode>(id, this, model);
return new Folder<DefaultMutableTreeNode>(id, this, model);
}
};
myTestTree.setOutputMarkupId(true);
myTestTree.add(new WindowsTheme());
myTestTree.getTable().add(AttributeModifier.replace("style", "width: 100%; background-color:white;"));
addOrReplace(myTestTree);
}
private List<? extends IColumn<DefaultMutableTreeNode, String>> createColumns() {
columns.add(new TreeColumn<>(new Model("Tree"), "obj.text"));
columns.add(new PropertyColumn<>(new Model("FileStatus"), "FileStatus", "obj.fileStatus"));
columns.add(new PropertyColumn<>(new Model("StartDate"), "StartDate", "obj.startDate"));
columns.add(new PropertyColumn<>(new Model("LastDate"), "LastDate", "obj.lastDate"));
columns.add(new PropertyColumn<>(new Model("Count"), "Count", "obj.count"));
return columns;
}
In tree table view, columns headers are not displaying "Tree",
"FileStatus", "StartDate", "LastDate", "Count".
任何人都可以在这里帮助如何在树 table 中显示树 table 列的 header 吗?会更有价值。
我在 TreeTable 中添加 ToptoolBar 和 BottomToolBar 后解决了这个问题。
**myTestTree.getTable().addTopToolbar(new HeadersToolbar<String>(treeImport.getTable(), testSortableDataProvider()));
myTestTree.getTable().addBottomToolbar(new NoRecordsToolbar(treeImport.getTable()));**
private ISortableDataProvider<DefaultMutableTreeNode, String> testSortableDataProvider() {
ISortableDataProvider<DefaultMutableTreeNode, String> ret = new SortableDataProvider<DefaultMutableTreeNode, String>() {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
@Override
public Iterator<? extends DefaultMutableTreeNode> iterator(long arg0, long arg1) {
return null;
}
@Override
public IModel<DefaultMutableTreeNode> model(DefaultMutableTreeNode arg0) {
return null;
}
@Override
public long size() {
return 0;
}
};
return ret;
}
如果 addTopToolbar 方法中有一个空值,那么它将不起作用。
myTestTree.getTable().addTopToolbar(new HeadersToolbar<String>(treeImport.getTable(), null));
所以它应该用 sortable 数据提供者来定义,这将解决这个问题以显示树 table 列 header 显示问题。
myTestTree.getTable().addTopToolbar(new HeadersToolbar<String>(treeImport.getTable(), testSortableDataProvider()));
private void myTreePage() {
private final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("<root>");
DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
statusImport();
ITreeProvider<DefaultMutableTreeNode> modelProvider = new TreeModelProvider<DefaultMutableTreeNode>(treeModel, false) {
private static final long serialVersionUID = 1L;
@Override
public IModel<DefaultMutableTreeNode> model(DefaultMutableTreeNode object) {
return Model.of(object);
}
};
TableTree<DefaultMutableTreeNode, String> myTestTree = new TableTree<DefaultMutableTreeNode, String>("myTestTreeTable", createColumns(), modelProvider, Long.MAX_VALUE) {
private static final long serialVersionUID = 1L;
@Override
protected Component newContentComponent(String id, IModel<DefaultMutableTreeNode> model) {
//return new CheckedFolder<DefaultMutableTreeNode>(id, this, model);
return new Folder<DefaultMutableTreeNode>(id, this, model);
}
};
myTestTree.setOutputMarkupId(true);
myTestTree.add(new WindowsTheme());
myTestTree.getTable().add(AttributeModifier.replace("style", "width: 100%; background-color:white;"));
addOrReplace(myTestTree);
}
private List<? extends IColumn<DefaultMutableTreeNode, String>> createColumns() {
columns.add(new TreeColumn<>(new Model("Tree"), "obj.text"));
columns.add(new PropertyColumn<>(new Model("FileStatus"), "FileStatus", "obj.fileStatus"));
columns.add(new PropertyColumn<>(new Model("StartDate"), "StartDate", "obj.startDate"));
columns.add(new PropertyColumn<>(new Model("LastDate"), "LastDate", "obj.lastDate"));
columns.add(new PropertyColumn<>(new Model("Count"), "Count", "obj.count"));
return columns;
}
In tree table view, columns headers are not displaying "Tree", "FileStatus", "StartDate", "LastDate", "Count".
任何人都可以在这里帮助如何在树 table 中显示树 table 列的 header 吗?会更有价值。
我在 TreeTable 中添加 ToptoolBar 和 BottomToolBar 后解决了这个问题。
**myTestTree.getTable().addTopToolbar(new HeadersToolbar<String>(treeImport.getTable(), testSortableDataProvider()));
myTestTree.getTable().addBottomToolbar(new NoRecordsToolbar(treeImport.getTable()));**
private ISortableDataProvider<DefaultMutableTreeNode, String> testSortableDataProvider() {
ISortableDataProvider<DefaultMutableTreeNode, String> ret = new SortableDataProvider<DefaultMutableTreeNode, String>() {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
@Override
public Iterator<? extends DefaultMutableTreeNode> iterator(long arg0, long arg1) {
return null;
}
@Override
public IModel<DefaultMutableTreeNode> model(DefaultMutableTreeNode arg0) {
return null;
}
@Override
public long size() {
return 0;
}
};
return ret;
}
如果 addTopToolbar 方法中有一个空值,那么它将不起作用。
myTestTree.getTable().addTopToolbar(new HeadersToolbar<String>(treeImport.getTable(), null));
所以它应该用 sortable 数据提供者来定义,这将解决这个问题以显示树 table 列 header 显示问题。
myTestTree.getTable().addTopToolbar(new HeadersToolbar<String>(treeImport.getTable(), testSortableDataProvider()));