有人可以解释一件事吗?是否可以将Vaadin TreeTable与LazyQueryContainer一起使用?我已经尝试了但它不起作用。实际上,没有任何延迟加载。调用org.vaadin.addons.lazyquerycontainer.Query的方法 loadItems ,直到加载所有数据。对于instanse,如果容器的批量大小= 100并且我有500行,则此方法将被调用5次。这是我的代码:
public class LazyHierarchicalQueryContainer extends LazyQueryContainer implements Container.Hierarchical {
private String parentProperty = "parent";
public LazyHierarchicalQueryContainer(QueryFactory queryFactory, Object idPropertyId, int batchSize,
boolean compositeItems) {
super(queryFactory, idPropertyId, batchSize, compositeItems);
}
public LazyHierarchicalQueryContainer(QueryDefinition queryDefinition, QueryFactory queryFactory) {
super(queryDefinition, queryFactory);
}
public LazyHierarchicalQueryContainer(QueryView queryView) {
super(queryView);
}
public String getParentProperty() {
return parentProperty;
}
public void setParentProperty(String parentProperty) {
this.parentProperty = parentProperty;
}
@Override
public Collection<?> getChildren(Object itemId) {
return Collections.emptyList();
}
@Override
public Object getParent(Object itemId) {
return null;
}
@Override
public Collection<?> rootItemIds() {
ArrayList arrayList = new ArrayList();
for (Object workItem : getItemIds()) {
if (isRoot(workItem)) {
arrayList.add(workItem);
}
}
return arrayList;
}
@Override
public boolean setParent(Object itemId, Object newParentId) throws UnsupportedOperationException {
if (getItem(newParentId) != null) {
getItem(itemId).getItemProperty(getParentProperty()).setValue(newParentId);
} else {
getItem(itemId).getItemProperty(getParentProperty()).setValue(null);
}
return true;
}
@Override
public boolean areChildrenAllowed(Object itemId) {
return true;
}
@Override
public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) throws UnsupportedOperationException {
return false;
}
@Override
public boolean isRoot(Object itemId) {
return getItem(itemId).getItemProperty(parentProperty).getValue() == null;
}
@Override
public boolean hasChildren(Object itemId) {
return false;
}
}
提前致谢。
答案 0 :(得分:0)
看来你的rootItemIds()实现加载所有项来过滤掉根项。这可能会导致整个容器在第一时间被读取。