javascript noob。我正在潜入并设法使用此库springy.js获得强制布局图设置。但是我不知道如何选择一个节点(我想做一个onclick并触发一些ajax)。使用下面的代码(在我的html中),我不断收到图表未定义的错误。
的javascript
var graphJSON = {"nodes":["1","2","3","4","5","6"],"edges":[["4","3"],["3","4"],["3","3"],["4","4"]]};
jQuery(function(){
var graph = new Springy.Graph();
graph.loadJSON(graphJSON);
var springy = jQuery('#springydemo').springy({
graph: graph
});
});
jQuery('#springydemo').springy({ graph: graph, nodeSelected: function(node) {
alert(node.data.label);
} });
HTML:
<canvas id="my_canvas" width="600" height="400" />
这是我的jsfiddle
答案 0 :(得分:0)
挂断它。这一切都包裹在jquery中。这应该是它的样子:
private DataTable _dataTable;
protected void Page_Load(object sender, EventArgs e)
{
InitializeTable();
}
private void InitializeTable()
{
if (_dataTable != null) return;
_dataTable = new DataTable();
DataColumn dc = new DataColumn("Name");
_dataTable.Columns.Add(dc);
}
protected void Buton1_Click(object sender, EventArgs e)
{
DataRow dr = _dataTable.NewRow();
dr["Name"] = TextBox1.Text;
_dataTable.Rows.Add(dr);
_dataTable.AcceptChanges();
GridView1.DataSource = _dataTable;
GridView1.DataBind();
}