JSON用getorgchart创建树

时间:2018-05-31 07:20:31

标签: getorgchart

我使用getOrgChart创建一个树。 我想在JSON中做它,除了它不保持键的顺序。 是否真的有必要在例子中有一个有序的JSON?

(Id; Name; Title; ...)

([{"Id":"1","ParentId":"","Name":"Luke Coleman","Title":"ESL teacher","Address":"31 Dalgarno Street COOCOOBOONAH NSW 2380","Phone":"(02) 6780 6577","Visa":null,"Image":"http://www.getorgchart.com/GetOrgChart/getorgchart-demos/images/f-19.jpg"},{"Id":"2","ParentId":"1","Name":"Zara Potter","Title":"Bricklayer","Address":"74 Main Street RAMCO SA 5322","Phone":null,"Visa":"4556 6703 4539 1908","Image":"http://www.getorgchart.com/GetOrgChart/getorgchart-demos/images/f-20.jpg"},{"Id":"3","ParentId":"1","Name":"Mohammed Cook","Title":"Nursing aide","Address":null,"Phone":"(03) 5300 7404","Visa":"4716 4797 6315 4724","Image":"http://www.getorgchart.com/GetOrgChart/getorgchart-demos/images/f-1.jpg"},{"Id":"4","ParentId":"1","Name":"Harley Birch","Title":"Reservation agent","Address":"70 Cornish Street WILLIAMS RAAF VIC 3027","Phone":"(03) 8336 9859","Visa":"5442 1396 6319 2111","Image":"http://www.getorgchart.com/GetOrgChart/getorgchart-demos/images/f-3.jpg"},{"Id":"5","ParentId":"2","Name":"Maya Ford","Title":"Reservation agent","Address":"70 Cornish Street WILLIAMS RAAF VIC 3027","Phone":"(03) 8336 9859","Visa":"5442 1396 6319 2111","Image":"http://www.getorgchart.com/GetOrgChart/getorgchart-demos/images/f-5.jpg"}]);

因为在我这边,当创建自动创建的JSON时,我得到第二个位置的id,我读到我们无法更改顺序。

{"Statut":"Test","id":106,"Image":"Test.gif","Nom":"Test","Heure":"17-05-2018 14:41:55","parentId":"","Compteur":10000}

1 个答案:

答案 0 :(得分:0)

您可以显式指定idField和parentIdField

以下是一个例子:

if (chkVal === true) {
    $(elmId).removeClass("sortable");
} else {
    $(elmId).addClass("sortable");
}