cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

tree table component with auto expanded nodes

PN_5076692
10-Marble

tree table component with auto expanded nodes

Hello,

 

for one of my customers I've created a wizard step with some change validation info.

the data is arranged in a flat tree structure which is displayed in the treetable component.

See attached example screenshot.

One requirement is that non "green" checks are auto expanded for the user.

 

I tried to implement it as described in the customizers guide, but so far no luck.

 

The TreeTable component uses a custom AbstractConfigurableTableBuilder with an custom ExpansionStateManager


the table config looks like this

 

 

 

JcaTreeConfig treeCfg = (JcaTreeConfig) factory.newTreeConfig();

        treeCfg.setDataSourceMode(DataSourceMode.DISABLED);
        treeCfg.setType(Object.class.getName());
        treeCfg.setTargetObject("origObject");
        treeCfg.setComponentMode(ComponentMode.VIEW);
        treeCfg.setActionModel("tcw tcwValidation table");
        //treeCfg.setMenubarName("tcw tcwValidation table");

        treeCfg.setId(TCW_TCWVALIDATION_TABLE_ID);
        treeCfg.setLabel(WTMessage.getLocalizedMessage(TCW_RESOURCE, "tcw.validationTable.title", (Object[]) null, SessionHelper.getLocale()));

        treeCfg.setNodeColumn(TCW_VAL_COLID_VALTYPE);

        treeCfg.setShowTreeLines(true);
        treeCfg.setExpansionLevel(DescriptorConstants.TableTreeProperties.FULL_EXPAND);

        treeCfg.setFindInTableEnabled(false);
        treeCfg.setFindInTableMode(FindInTableMode.DISABLED);
        treeCfg.setShowCount(true);

        treeCfg.setDisableAction("false");
        treeCfg.setRowBasedObjectHandle(true);

        addColumn(TCW_VAL_COLID_VALTYPE, treeCfg, factory, true, false, false);
        addColumn(TCW_VAL_COLID_CHECKTYPE, treeCfg, factory, true, false, false);
        addColumn(TCW_VAL_COLID_MESSAGE, treeCfg, factory, true, false, false);
        addColumn(TCW_VAL_COLID_RESULTTYPE, treeCfg, factory, true, false, false);
        if (isTCWWizardMode) {
            addColumn(TCW_VAL_COLID_ACTION, treeCfg, factory, true, false, false);
            addColumn(TCW_VAL_COLID_RELATEDOBJ, treeCfg, factory, true, false, false);
        }

 

 

 

 

the root nodes list is build like this

 

 

 

        List rootNodes = new ArrayList();
        for (TCWValidationCheckType t : topChecks) {
            TCWValidationBean rowBean = new TCWValidationBean(t);
            rowBean.setModelContext(modelContext);
            rowBean.setHasChildren(true);
            rowBean.setDepth(1);
            if ("INFO".equals(t.getCheckResult())) {
                if (!"hideAllGreen".equals(resultFilter)) {
                    addExpandedNode(rowBean);
                    rootNodes.add(rowBean);
                }
            } else if (!"SUCCESS".equals(t.getCheckResult())) {
                // check is not ok, add to auto expand list
                addExpandedNode(rowBean);
                rootNodes.add(rowBean);
            } else {
                if (!"hideAllGreen".equals(resultFilter)) {
                    rootNodes.add(rowBean);
                }
            }
        }
        if (rootNodes.isEmpty()) {
            // add entry "all successfull"
            String x = WTMessage.getLocalizedMessage(TCW_RESOURCE,"tcw.validation.summarymessage.allchecksok", (Object[]) null, SessionHelper.getLocale());
            TCWValidationBean rowBean = new TCWValidationBean(x);
            rootNodes.add(rowBean);
            addExpandedNode(rowBean);
        }

 

 

 

 

the overriden method isExpandNeeded looks like this

 

 

 

    @Override
    public boolean isExpandNeeded(Object beanObjIn, int level) throws WTException {
        boolean expandNeeded = false;
        if (beanObjIn instanceof TCWValidationBean) {
            TCWValidationBean tcwValBean = (TCWValidationBean) beanObjIn;
            if (this.getExpandedOids() != null && tcwValBean.getOid() != null && this.getExpandedOids().contains(tcwValBean.getOid().toString())) {
                expandNeeded = true;
            }
        } 
        return expandNeeded;
    }

 

 

 

 

setting the root nodes for expand & setting everything to expand_full seems to have no effect.

there are no errors or hints in the log unfortunately.

manual by the user "expand" works without a problem.

 

any suggestions maybe? what did I forget/miss? 😉

 

THANKS!

 

ACCEPTED SOLUTION

Accepted Solutions

Hi @PN_5076692 

I've never found a way how to expand the tree automatically by API. 

As you've mentioned  the expand_full really does not work at all. 

 

I usually add an action expand all for user to the table menu. 

PetrH

View solution in original post

3 REPLIES 3

Hi @PN_5076692 

I've never found a way how to expand the tree automatically by API. 

As you've mentioned  the expand_full really does not work at all. 

 

I usually add an action expand all for user to the table menu. 

PetrH

Hello @HelesicPetr 

 

well, that's unfortunate. 😕 

In the meantime I tried different approaches but so far no luck.

 

It seems that I would need to create some additional JS code and simulate onClick event to expand certain entries.

(Like your proposal)

 

Regards

olivierlp
Community Manager
(To:PN_5076692)

Hi @PN_5076692 ,
I wanted to see if you got the help you needed.
If so, please mark the appropriate reply as the Accepted Solution. It will help other members who may have the same question.
Of course, if you have more to share on your issue, please pursue the conversation. 

Thanks,

Olivier
Announcements

Top Tags