2014-02-18 39 views
0

我有一個頁面,我想要jit Spacetree和jqgrid。但它正確顯示jqgrid或Spacetree。我通過AJAX請求加載JSON數據的Spacetree。 根節點永遠不會到來,但所有其他節點都來了,它是完全正常工作的。如果我刪除jqgrid包括然後樹加載與根節點。 我已經使用如何在同一頁面上使用jit spacetree和jqgrid?

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; 
     } 
    }); 

我有spacetree的該示例使用此jqgrid

http://jsfiddle.net/amorris/yNw3C/

我已經包括以下的HTML

  • 的jqGrid-4.4.5-SRC/ui.jqgrid.css文件,
  • 的jqGrid-4.4.5-SRC/jquery.jqGrid.js,
  • 的jqGrid-4.4.5-SRC/jQuery的ui.css,
  • 的jqGrid-4.4.5-SRC/grid.locale-en.js,

回答

0

這是因爲所使用的jqGrid命名約定和spacetree。兩者都創建相同的ID。 jqgrid創建了id = 1的行,而spacetree也創建了id = 1的div。現在,當創建樹的節點時,dom通過id獲取div。由於jqgrid首先加載,所以dom得到了jqgrid行的id而不是div。我通過添加前綴來改變jqgrid id創建過程。現在它正在工作。

相關問題