Recenter orgchart on selected node

2 Answers 22 Views
OrgChart
Alfred
Top achievements
Rank 1
Alfred asked on 16 Feb 2025, 10:39 PM

When using the orgchart for a large set of nodes (2000+) it can be cumbersome to find where you are when a node is expanded. Is there a way to keep the just expanded node selected?

I've added an event handled to the Expand event which is called correct.


<script>
    function onExpand(e) {
//        alert("event: Expand --> " + e.dataItems[0].title + " expanded");
        alert(e.dataItems[0].id);
        var orgChart = $("orgChart").getKendoOrgChart();
        orgChart.select(e.dataItems[0]);
    }    
</script>

 

The alert fires with the correct id but dosen't seem to select the node that was clicked. I'd like to have that selected so the end user doesn't lose their place as the orgchart expands. Thanks!

 

2 Answers, 1 is accepted

Sort by
0
Ivaylo
Telerik team
answered on 19 Feb 2025, 03:34 PM

Hi Alfred,

I am still reviewing this scenario and will need a bit more time. I will get back with an update tomorrow.

Regards,
Ivaylo
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Ivaylo
Telerik team
answered on 20 Feb 2025, 07:25 AM

Hi Alfred,

The Expand event provides access to the expanding node through the item parameter. This node could be selected, and the scrollIntoView method could be utilized to bring it into the view. Below is an example of the implementation:

//C#
.Events(e => e.Expand("onExpand"))

//JS
function onExpand(e) {
    var node = e.item[0];
    e.sender.select(node); 
    node.scrollIntoView({ behavior: "smooth", block: "center", inline: "center" });
}

Furthermore, I prepared a sample REPL where the suggested implementations could be tested. Please let me know if this is the desired result.

I hope this information was helpful.

Kind Regards,
Ivaylo
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
OrgChart
Asked by
Alfred
Top achievements
Rank 1
Answers by
Ivaylo
Telerik team
Share this question
or