gpt4 book ai didi

javascript - 如何在 OrgChart 中隐藏子节点并显示父节点

转载 作者:行者123 更新时间:2023-11-28 03:41:52 25 4
gpt4 key购买 nike

我目前正在实现 dabeng 的 OrgChart ( https://github.com/dabeng/OrgChart ),希望在加载组织结构图时显示父节点并隐藏子节点。

我有以下代码,我假设添加了显示父节点的选项,但这不起作用:

$.fn.orgchart = function (options) {
var defaultOptions = {
'nodeTitle': 'name',
'nodeUIMID': 'uim_id',
'nodeJobTitle': 'title',
'nodeFaculty': 'faculty',
'nodeDepartment': 'department',
'nodeSubSection': 'sub_section',
'nodeUrl': 'url',
'nodeId': 'id',
'toggleSiblingsResp': false,
'depth': 999,
'chartClass': '',
'exportButton': false,
'exportFilename': 'OrgChart',
'exportFileextension': 'png',
'draggable': false,
'direction': 't2b',
'pan': true,
'zoom': true,
'zoominLimit': 2,
'zoomoutLimit': 0.5,
'showParent': true,
'hideChildren': true
};

switch (options) {
case 'showParent':
return showParent.apply(this, Array.prototype.splice.call(arguments, 1));
case 'hideChildren':
return hideChildren.apply(this, Array.prototype.splice.call(arguments, 1));
default: // initiation time
var opts = $.extend(defaultOptions, options);
}

// build the org-chart
var $chartContainer = this;
var data = opts.data;
var $chart = $('<div>', {
'data': { 'options': opts },
'class': 'orgchart' + (opts.chartClass !== '' ? ' ' + opts.chartClass : '') + (opts.direction !== 't2b' ? ' ' + opts.direction : ''),
'click': function (event) {
if (!$(event.target).closest('.node').length) {
$chart.find('.node.focused').removeClass('focused');
}
}
});

构建图表时是否需要调用showParent函数?

最佳答案

@user3565164您可以使用以下代码片段:

var oc = $('#chartContainerId').orgchart({
...

'initCompleted': function() {
oc.hideChildren($('#chart-container').find('.node:first'));
}
});

关于javascript - 如何在 OrgChart 中隐藏子节点并显示父节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48864338/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com