BALKANGraph / OrgChartJS

OrgChart JS is a simple, flexible and highly customizable organization chart plugin for presenting the structure of your organization and the relationships in an elegant way.
https://balkan.app/orgchartjs
250 stars 85 forks source link

Cannot edit custom template sublevel links #815

Closed george-seed closed 8 months ago

george-seed commented 8 months ago

I am building an org-chart and am having an issue with my custom template for filtered items. Specifically I want to prevent sublevel links from rendering.

I know I can change the rendering for sublevels at the templates level, but this removes sublevel links for my entire org-chart.

OrgChart.templates.subLevel.link = '';

If I'm using a custom template (to remove nodes when filtering) there is access for link, no access for subLevel.link - it does not appear to be available for custom templates.

OrgChart.templates.filtered = Object.assign({}, OrgChart.templates.ana);
OrgChart.templates.filtered.size = [0, 0];
OrgChart.templates.filtered.node = '';
OrgChart.templates.filtered.link = '';
OrgChart.templates.filtered.subLevel.link = ''; // THIS WILL CAUSE AN ERROR

So when I want to filter the tree and apply my custom template to the nodes that are to be filtered out

tags: {
    filter: {
        template: 'filtered',
    },

Everything gets the custom template except for subLevel links which remain visible.

Is this a feature that is available, or is there an alternative way to do this?

It's frustrating to be able to customise links but not the sublevel links. It means when I am filtering my org chart I end up with lines remaining.

ZornitsaPesheva commented 8 months ago

Here isa code demo on how to hide sublevel nodes: https://code.balkan.app/org-chart-js/hide-sublevel-links-for-filtered-nodes#JS

george-seed commented 8 months ago

Fantastic, this is a very nice solution. Happy to close this as resolved.