0

我已经尝试过 gridview:ture , loadui:block 但加载后显示 treegrid 仍然需要更多时间。我的 json 包含超过 2044 个数据。我正在使用 Firefox 3.6 版

我的代码如下

**

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

1 回答 1

0

我终于得到了我的问题的答案。我现在能够将大量数据自动放入 treegrid 中。

我使用了 treegrid 邻接模型 aud 按需自动加载树。但是我的树节点被加载到 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});
                        }

                    }



            },

    });

}
于 2012-05-16T10:11:57.790 回答