Производительность древовидной сетки Jqgrid

Я пробовал gridview:ture , loadui:block , но для отображения древовидной сетки после загрузки требуется больше времени. мой 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;
}

person Shweta Tiwari    schedule 24.04.2012    source источник


Ответы (1)


Наконец-то я получил ответ на свой вопрос. Теперь я могу автоматически вводить большое количество данных в древовидную сетку.

Я использовал модель смежности древовидной сетки и автоматически загружал дерево по требованию. Но мой узел дерева загружается на 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});
                        }

                    }



            },

    });

}
person Shweta Tiwari    schedule 16.05.2012