Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var miArray= [
- { nivel:"Cluster", cantidad:4 },
- { nivel:"Sección", cantidad:3 },
- { nivel:"Manzanas", cantidad:2 },
- ];
- Manzanas 1
- Manzanas 2
- Manzanas 1
- Manzanas 2
- Manzanas 1
- Manzanas 2
- Manzanas 1
- Manzanas 2
- Manzanas 1
- Manzanas 2
- Manzanas 1
- Manzanas 2
- $('#using_json_2').jstree({ 'core' : {
- 'data' : [
- { "id" : "ajson1", "parent" : "#", "text" : "Simple root node" },
- { "id" : "ajson2", "parent" : "#", "text" : "Root node 2" },
- { "id" : "ajson3", "parent" : "ajson2", "text" : "Child 1" },
- { "id" : "ajson4", "parent" : "ajson2", "text" : "Child 2" },
- ]
- } });
- var miArray= [
- { nivel:"Cluster", cantidad:4 },
- { nivel:"Sección", cantidad:3 },
- { nivel:"Manzanas", cantidad:2 },
- ];
- var data = [];
- recorreNiveles(miArray);
- console.log(data);
- function recorreNiveles(niveles){
- var copy = niveles;
- if (niveles !== undefined && niveles.length){
- for (var f =0; f < niveles.length; f++){
- var item = niveles[f];
- console.log("nivel:"+item.nivel+"_"+f)
- for (var g =0; g < item.cantidad; g++) {
- console.log("nivel:"+item.nivel+"_"+g)
- console.log('length:'+copy.length);
- recorreNiveles(copy.shift());
- /*
- for (var h=g+1; h < niveles.length; h++ ){
- var nivel = niveles[h];
- console.log(nivel);
- for (var i = 0; i < nivel.cantidad; i++){
- console.log(" nivel:"+nivel.nivel+"_"+i)
- }
- }
- */
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment