hi, i found this Google tree view code to generate a tree view. i modified it little bit to make it more simpler. here it is.
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Name');
data.addColumn('string', 'Manager');
data.addRows([['Mike',''], ['Jim', 'Mike'], ['Alice', 'Mike'],['Bob', 'Jim'],['Carol', 'Jim']]);
var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
chart.draw(data, { allowHtml: true });
}
but to make it dynamic i have to provide data from db(from C# page). for that i did this.
protected void Page_Load(object sender, EventArgs e)
{
String csname1 = "PopupScript";
Type cstype = this.GetType();
ClientScriptManager cs = Page.ClientScript;
if (!cs.IsStartupScriptRegistered(cstype, csname1))
{
StringBuilder cstext1 = new StringBuilder();
cstext1.Append("<script type=text/javascript>");
cstext1.Append("function drawChart() {");
cstext1.Append("var data = new google.visualization.DataTable();");
cstext1.Append("data.addColumn('string', 'Name'); data.addColumn('string', 'Manager');");
cstext1.Append("data.addRows([['Mike',''], ['Jim', 'Mike'], ['Alice', 'Mike'],['Bob', 'Jim'],['Carol', 'Jim']]);");
cstext1.Append("var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));");
cstext1.Append("chart.draw(data, { allowHtml: true });");
cstext1.Append("}");
cstext1.Append("google.setOnLoadCallback(drawChart);");
cstext1.Append("</script>");
cs.RegisterStartupScript(cstype, csname1, cstext1.ToString());
}
}
but after loading the page is blank..no data is showing.. my intention is to change the 2d array with an own variable which will hold the array. I kept the array as it was.
kindly solve the issue.
thanks..