OrgChart icon indicating copy to clipboard operation
OrgChart copied to clipboard

请问数据源中的 otherPro 属性 应该怎么用呀?

Open janice-xu opened this issue 4 years ago • 2 comments

请问数据源中的 otherPro 属性 应该怎么用呀?

janice-xu avatar Feb 23 '21 01:02 janice-xu

Hi @janice-xu 你说的是这个片段吧'otherPro': anyValue // feel free to append any useful properties 其实意思就是说你可以在数据源中追加任意的字段,只要你觉得对渲染组织结构图中的节点或任何其他业务逻辑有帮助。这些“otherPro”可以在你构造节点时读取到,或者创建完节点的callback时读取到,总之就是你想在和节点交互时,需要一些辅助信息,就可以放在数据源里备用。

dabeng avatar Feb 25 '21 06:02 dabeng

可以看下这个例子(https://codepen.io/dabeng/pen/oNYwVQK) 中的代码片段:

            { 'name': 'Hei Hei', 'title': 'senior engineer',
              'specialProp': 123,
              'children': [
      'createNode': function($node, data) {
        $node.on('click', function() {
          alert(data.name + ' - ' + data.title + (data.specialProp || ''));
        });
      }

当你点击了“Hei Hei”这个节点的时候,data参数是包含了你每个节点的数据源信息的。

dabeng avatar Feb 25 '21 06:02 dabeng