PDA

View Full Version : Filter on asynchronous tree



Gordon25
25 Aug 2010, 11:20 PM
Hello,

I have a asynchronous tree and filter. Applying the filter after the loading of the tree. The first load displays the root node. When expanding the root, children are loaded in a store.

My problem is that, When a root node is loaded, the filter is applied and i can not expand the node. Because the filter automatically expands nodes.

My filter :



private void initFilter() {
m_filterFunctionType = new StoreFilter<BeanModel>() {
@Override
public boolean select(Store<BeanModel> store, BeanModel parent, BeanModel item, String property) {
BeanModel model = (BeanModel)item;
if(model != null){
TreeNodeDto treeNode = TreeUtils.getTreeNode(model);
if (treeNode != null) {
String type = treeNode.getType();
if (type.equals(SimpleLocalizationDefinitionDto.class.getName()) || type.equals(ProviderDto.class.getName())) {
return true;
}
if (type.equals(SimpleDeviceDto.class.getName())) {
DeviceTreeNodeDto deviceTreeNodeDto = (DeviceTreeNodeDto)model.getBean();
for (FunctionTypeDto deviceFunctionTypeDto : deviceTreeNodeDto.getFunctionType()) {
for (FunctionTypeDto functionTypeDto : m_listFunctionTypeDto) {
if(deviceTreeNodeDto.getFunctionType().size()>0){
if(deviceFunctionTypeDto.equals(functionTypeDto)){
for (DeviceSubTypeEnumDto deviceSubTypeEnumDto : m_listDeviceSubTypeDto) {
if(deviceTreeNodeDto.getDeviceSubTypeId().equals(deviceSubTypeEnumDto.getId())){
return true;
}
}
}
}
}
}
}
}
}
return false;
}
};

m_treePanel.getStore().addFilter(m_filterFunctionType);
}




m_treePanel.getStore().getLoader().addLoadListener(new LoadListener(){
// Retirer le filtre avant le chargement de l'arbre pour eviter le bug de l'arbre qui disparait lors du changement de vue
@Override
public void loaderBeforeLoad(LoadEvent le) {
super.loaderBeforeLoad(le);
m_treePanel.getStore().removeFilter(m_filterFunctionType);

}
// Ajouter le filtre après chargement de l'arbre
@Override
public void loaderLoad(LoadEvent le) {
super.loaderLoad(le);
m_treePanel.getStore().addFilter(m_filterFunctionType);
m_treePanel.getStore().applyFilters("");
}

});

Gordon25
25 Aug 2010, 11:49 PM
Can we stop the filter to extend the nodes?

Gordon25
25 Aug 2010, 11:58 PM
I added the option :


m_treePanel.setExpandOnFilter(false);


but when I extend the node, children do not load WHY ?

igrcic
26 Mar 2011, 3:54 PM
Hi Gordon,

have you maybe find solution to this? Tnx