Skip to content

Instantly share code, notes, and snippets.

@magirtopcu
Created February 14, 2018 22:36
Show Gist options
  • Save magirtopcu/c5c7183fcfb2baae6f5e29d8a13b9844 to your computer and use it in GitHub Desktop.
Save magirtopcu/c5c7183fcfb2baae6f5e29d8a13b9844 to your computer and use it in GitHub Desktop.
E devlet Alt Üst Soy bilgisini table'dan tree'ye çevirir
var temp1 =[];
$(".resultTable.striped tr").each(function(){
var k = [];
$(this).find("td").each(function(){
k.push($(this).text());
});
temp1.push(k);
});
temp1.splice(0,1);
temp1.reverse();
temp1.splice(0,2);
var put = function(index,list,item, root){
if(list[0]=="Kendisi"){
root.data = item;
root.id = index;
arl.push({key : index, title : item[7], name :item[3]+" "+item[4]});
}
else if(list[0]=="Annesi"){
root.annesi = {};
root.annesi.data =item;
root.annesi.id = index;
root.annesi.parentId = root.id;
arl.push({key : index, title : item[7], name :item[3]+" "+item[4], parent : root.id});
}
else if(list[0]=="Babası"){
root.babasi = {};
root.babasi.data = item;
root.babasi.id = index;
root.babasi.parentId = root.id;
arl.push({key : index,title : item[7], name :item[3]+" "+item[4], parent : root.id});
}
else if(list[0]=="Annesinin"){
list.splice(0,1);
put(index,list,item,root.annesi);
}
else if(list[0]=="Babasının"){
list.splice(0,1);
put(index,list,item,root.babasi);
}
}
var root = {};
var arl = [];
for(var i = 0;i<temp1.length;i++){
var list = temp1[i][2].split(" ");
put(i,list,temp1[i],root);
}
var gojsData = { "class": "go.TreeModel", "nodeDataArray": arl };
//https://gojs.net/latest/samples/orgChartEditor.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment