2012-04-24 45 views
0

我已經嘗試gridview:ture,loadui:塊,但仍然需要更多時間來顯示加載後的treegrid。我的json包含更多2044年的數據。我使用火狐3.6版Jqgrid treegrid性能

我的代碼如下

給**

Glcm= [{name:'id',index:'id', label:'Id',hidden:true,key:true, Enabled:false,jsonmap:"id"},{name:'text',index:'text',label:'Global Ledger',width:400,jsonmap:"text",formatter:gLCheckbox},{name:'additionalInfo',index:'additionalInfo',label:'additionalInfo',hidden:true,jsonmap:"additionalInfo"}, 
], 

**

GlTree.jqGrid({ 
       url: 'GlTreeStructure.action', 
       datatype: "json", 
       mtype: "POST", 
       colModel:Glcm, 
       width:outerwidthGL, 
       height:300, 
       rowNum:-1, 
       pager: '#ptreeList', 
       viewrecords: true, 
       caption:"Global Ledger", 
       toolbar: [true,"top"], 
       gridview:true, 
       treeGrid: true, 
       pginput:false, 
       pgtext:"", 
       pgbuttons:false, 
       loadui:'block', 
       deepempty:true, 
       ignoreCase: true, 
       autoencode:true, 
       jsonReader :{root: 'glList', 
        cell:"", 
        repeatitems: false 
       }, 
       treeReader : { 
        level_field: "level", 
        left_field:"lft", 
        right_field: "rgt", 
        leaf_field: "isLeaf", 
        parent_id_field: "parentId", 
        expanded_field: "expanded", 
        loaded: "loaded" 
       }, 
       treedatatype: "json", 
       treeGridModel:'adjacency', 
       ExpandColClick: true, 
       loadonce:true, 
       ExpandColumn : 'text', 
//    cellSubmit: 'remote', 
       gridComplete:function() 
       { 
        myData = GlTree.jqGrid('getRowData'); 
       } 

     }); 

//這個函數是在格式化用於顯示單選按鈕

function gLCheckbox(amount,options,rData) 
{ 
    if(rData.additionalInfo === 'G') 
      return '<div id ="checkglId"><input type="radio" id="radioId" name ="radioName" value="' +rData.text+'" align = "center",offval="off" onclick="selectGLElement(\''+rData.id+'\');" />&nbsp;'+amount + '</div>'; 
    else 
      return amount; 
} 

回答

0

我終於得到了我的問題的答案。我現在可以將大量數據自動轉換爲treegrid。

我已經使用treegrid adjaceny模型aud自動加載樹的按需。但我的treenode在onSelectRow上加載。

onSelectRow: function(id){ 
      var data = $(this).jqGrid("getRowData", id); 
      getChildTree(data,data.glId); 


     } 

function getChildTree(postdata,id) 
{ 
    $.ajax({ 
      type: "GET", 
      url: "GlChildTreeStructure.action?glId="+id, 
      dataType: "json", 
      success: function(json){ 
       JsonDataObj = json; 
        for(var i=0;i<JsonDataObj.ChildTreeList.length;i++){ 
         if(JsonDataObj.ChildTreeList.isLeaf==true){ 
          //alert("JsonDataObj.ChildTreeList : "+JsonDataObj.ChildTreeList[i].glId) 
          $("#GlTreeStructureGrid").jqGrid("addChildNode",JsonDataObj.ChildTreeList[i].glId, JsonDataObj.ChildTreeList[i].parentId, 
             { 
             "glId":JsonDataObj.ChildTreeList[i].glId, 
             "text":JsonDataObj.ChildTreeList[i].text, 
             "additionalInfo":JsonDataObj.ChildTreeList[i].additionalInfo, 
             "alternativeParent":JsonDataObj.ChildTreeList[i].alternativeParent, 
             "parentId":JsonDataObj.ChildTreeList[i].parentId, 
             "parent":JsonDataObj.ChildTreeList[i].parentId, 
             "dataType":JsonDataObj.ChildTreeList[i].dataType, 
             "periodType":JsonDataObj.ChildTreeList[i].periodType, 
             "glPresentationOrder":JsonDataObj.ChildTreeList[i].glPresentationOrder, 
             "extendedLink":JsonDataObj.ChildTreeList[i].extendedLink, 
             "parentCalculation":JsonDataObj.ChildTreeList[i].parentCalculation, 
             "isLeaf":JsonDataObj.ChildTreeList[i].isLeaf, 
             "level":JsonDataObj.ChildTreeList[i].level, 
             "lft":JsonDataObj.ChildTreeList[i].lft, 
             "expanded":JsonDataObj.ChildTreeList[i].expanded, 
             "loaded":JsonDataObj.ChildTreeList[i].loaded, 
             "icon":JsonDataObj.ChildTreeList[i].icon, 
             "rgt":JsonDataObj.ChildTreeList[i].rgt}); 

         }else{ 
         // alert("JsonDataObj.ChildTreeList : "+JsonDataObj.ChildTreeList[i].glId) 
          $("#GlTreeStructureGrid").jqGrid("addChildNode",JsonDataObj.ChildTreeList[i].glId, JsonDataObj.ChildTreeList[i].parentId, 
             { 
             "glId":JsonDataObj.ChildTreeList[i].glId, 
             "text":JsonDataObj.ChildTreeList[i].text, 
             "additionalInfo":JsonDataObj.ChildTreeList[i].additionalInfo, 
             "alternativeParent":JsonDataObj.ChildTreeList[i].alternativeParent, 
             "parentId":JsonDataObj.ChildTreeList[i].parentId, 
             "dataType":JsonDataObj.ChildTreeList[i].dataType, 
             "parent":JsonDataObj.ChildTreeList[i].parentId, 
             "periodType":JsonDataObj.ChildTreeList[i].periodType, 
             "glPresentationOrder":JsonDataObj.ChildTreeList[i].glPresentationOrder, 
             "extendedLink":JsonDataObj.ChildTreeList[i].extendedLink, 
             "parentCalculation":JsonDataObj.ChildTreeList[i].parentCalculation, 
             "isLeaf":JsonDataObj.ChildTreeList[i].isLeaf, 
             "level":JsonDataObj.ChildTreeList[i].level, 
             "lft":JsonDataObj.ChildTreeList[i].lft, 
             "expanded":JsonDataObj.ChildTreeList[i].expanded, 
             "loaded":JsonDataObj.ChildTreeList[i].loaded, 
             "icon":JsonDataObj.ChildTreeList[i].icon, 
             "rgt":JsonDataObj.ChildTreeList[i].rgt}); 
         } 

        } 



      }, 

    }); 

}