【问题标题】:How to replace "children:" with another keyword (e.g. "descdendants:")如何用另一个关键字替换“孩子:”(即“后代:”)
【发布时间】:2017-05-08 15:41:23
【问题描述】:

我有一个数据集,其层次结构对应于 fancytree 的 json 结构,除了“children:”被表示为“descendants:”。我似乎记得有一个选项可以告诉 fancytree 在数据集中使用另一个关键字作为“儿童”,但找不到它。有人可以帮帮我吗?

【问题讨论】:

  • 这有点含糊。你用的是哪个版本?你读过文档吗?你的结构是什么样的?你确定是否是用 fancytree 生成的(可能是它的一个分支)?
  • 通过查看代码,它似乎希望找到children 属性,并且不支持任何更改它的选项。

标签: javascript keyword fancytree


【解决方案1】:

转换输入数据的推荐方法是实现postProcess回调

postProcess: function(event, data) {
  var orgResponse = data.response;

  orgResponse.descendants = orgResponse.children;
  delete orgResponse.children;
}

(see also the docs):

【讨论】:

  • 感谢您的回答和 cmets,将使用 postProcess 替换字符串
  • 那么你应该接受和/或赞成这个答案...... ;)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-06
  • 2011-04-06
  • 1970-01-01
  • 2021-04-09
  • 2013-09-15
相关资源
最近更新 更多