Closed gmaison closed 3 years ago
In one of the nodes children
is not an array, but an object (with properties like "1" and "0"). This is why jstree can not render those children - it expects an array, make sure you have a proper array instead of an object. In PHP this can be achieved in many ways, one of which is to use array_values
on the children
key.
Hi,
first, as it is my first post, thanks a lot for this excellent plugin that saved my dev :)
i have the following JSON data (no important data) : [{"id":"1630920406109x242186816334594050","icon":"empty.png","state":{"selected":false,"opened":true},"a_attr":{"class":"ital"},"children":[{"id":"1630920419570x588515599383265300","icon":"empty.png","state":{"selected":false,"opened":true},"a_attr":{"class":"ital"},"children":[{"id":"1630920426901x345528786324291600","icon":"empty.png","state":{"selected":false,"opened":true},"a_attr":{"class":"ital"},"children":[],"poids":1,"text":"(1) Un.Un.Un - 3<\/small>"},{"id":"1630920436249x521848092768862200","icon":"empty.png","state":{"selected":false,"opened":true},"a_attr":{"class":"ital"},"children":[],"poids":1,"text":"(1) Un.Un.Deux - 4<\/small>"}],"poids":3,"text":"(3) Un.Un - 2<\/small>"},{"id":"1630920445045x651524216913395700","icon":"empty.png","state":{"selected":false,"opened":true},"a_attr":{"class":"ital"},"children":[],"poids":1,"text":"(1) Un.Deux - 5<\/small>"},{"id":"1630920450268x400980267835064300","icon":"empty.png","state":{"selected":false,"opened":true},"a_attr":{"class":"ital"},"children":[],"poids":1,"text":"(1) Un.Trois - 6<\/small>"}],"poids":6,"text":"(6) Un - 1<\/small>"},{"id":"1630920455704x205050497385103360","icon":"empty.png","state":{"selected":false,"opened":true},"a_attr":{"class":"ital"},"children":{"1":{"id":"1630920464029x689874171023327200","icon":"empty.png","state":{"selected":false,"opened":true},"a_attr":{"class":"ital"},"children":[{"id":"1630920469692x817260882104156200","icon":"empty.png","state":{"selected":false,"opened":true},"a_attr":{"class":"ital"},"children":[],"poids":1,"text":"(1) Deux.Deux.Un - 10<\/small>"}],"poids":2,"text":"(2) Deux.Deux - 9<\/small>"},"0":{"id":"1630920459936x736878838750117900","icon":"empty.png","state":{"selected":false,"opened":true},"a_attr":{"class":"ital"},"children":[],"poids":1,"text":"(1) Deux.Un - 8<\/small>"}},"poids":4,"text":"(4) Deux - 7<\/small>"},{"id":"1630920473820x307873589840838660","icon":"empty.png","state":{"selected":false,"opened":true},"a_attr":{"class":"ital"},"children":[],"poids":1,"text":"(1) Trois - 11<\/small>"}]
The thing is that it partially renders the tree as displayed in the joined screen shot.
i've checked the JSON syntax, but everything is fine. (it is recursively built). On another data sample, it's not the first item but the second one that is not generated... Although there's a lot of children for the first root item ("Bienveillance"), it doesn't show them but it does well for the next root item ("Il est souriant").
i'm using the CDNJS with the 3.3.12 version ...
Any hint ?
thanks a lot for any feedback
Best regards,
Guillaume