![](/img/trans.png)
[英]How do I convert CakePHP json to use with JS JIT SpaceTree?
[英]how to use jit spacetree and jqgrid on same page?
我有一個頁面需要jit Spacetree和jqgrid。 但是它可以正確顯示jqgrid或Spacetree。 我通過ajax請求使用json數據加載Spacetree。 根節點永遠不會到來,但是其他所有節點都來了,它是完全可用的。 如果我刪除jqgrid include,則帶有根節點的樹加載。 我已經使用了spacetree這個例子
http://philogb.github.io/jit/static/v20/Jit/Examples/Spacetree/example2.html
我已經用此功能替換了3行example2.js
st.loadJSON(eval( $.parseJSON(json)));
st.compute();
st.onClick(st.root);
獲取json數據的函數
$.ajax({
type: "POST",
url: "../default.aspx",
data: {Mode: 'Tree'},
dataType: "text",
success: function(response) {
var response = $.parseJSON(response);
//load json data
st.loadJSON(response);
//compute node positions and layout
st.compute();
//optional: make a translation of the tree
// st.geom.translate(new $jit.Complex(-200, 0), "current");
//emulate a click on the root node.
st.onClick(st.root);
// NodeId=st.root;
},
error: function(rs, e) {
//alert(rs.responseText);
return false;
}
});
我用過這個jqgrid
http://jsfiddle.net/amorris/yNw3C/
我在html中包含以下文件
這是因為jqgrid和spacetree使用了命名約定。 兩者都在創建相同的ID。 jqgrid正在創建id為= 1的行,而spacetree也正在創建id為= 1的div。 現在,在創建樹的節點時,dom通過id獲取div。 當jqgrid首先加載時,dom會獲取jqgrid行的ID而不是div。 我通過向其添加前綴來更改jqgrid id創建過程。 現在它正在工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.