简体   繁体   中英

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. 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. 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:

 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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