简体   繁体   English

遍历BasicPrimitives组织结构图项目

[英]Iterate over BasicPrimitives OrgChart Items

I'm using basic primitives org chart to create a family tree. 我正在使用基本图元组织结构图来创建家谱。 What I'd like to do is iterate over the items that have been rendered so I can save the json to the database. 我想做的是遍历已渲染的项目,以便可以将json保存到数据库中。 I've been looking over the site's reference and put this in my code: 我一直在查看该网站的参考,并将其放在我的代码中:

alert(primitives.famdiagram.ItemConfig.length);

$.each(primitives.famdiagram.ItemConfig, function (key, value) {
     alert(value.Id);
 });

for (var i=0; i < primitives.famdiagram.ItemConfig.length; i++)
   {
      alert(primitives.famdiagram.ItemConfig[i].Id);
   }

It gives me a length of 5, but when I try to iterate through the items with either jquery or javascript, nothing happens. 它的长度为5,但是当我尝试使用jquery或javascript遍历项目时,什么也没有发生。 How can I access the collection of items using basic primitives? 如何使用基本原语访问项目集合?

This appears to work and I'd just have to rebuild the json string: 这似乎可以正常工作,我只需要重建json字符串即可:

 var items = jQuery("#famdiagram").famDiagram("option", "items");
        $.each(items, function (key, value) {
            alert(value.id);
            alert(value.title);
            alert(value.parents);
        });

OR just save the items array in the DB as is. 或者只是将项目数组直接保存在数据库中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM