我有超過1000行通過jqGrid填充數據。當我通過jqGrid填充數據時,jqGrid花費超過20秒來填充數據。此時間僅由jqGird執行(查詢執行時間和其他時間除外)。我有一個要求,通過使用jqGrid填充1000行,我不想使用分頁。請幫助我如何提高jgGrid的性能。如何提高jqGrid的性能
我們使用的版本是: jgGrid:3.6.4 jQuery的:1.4.2 jQuery用戶界面:1.7.2 瀏覽器:IE 7
以下是代碼:
jQuery("#displayItemPerformanceGrid").jqGrid({
//datatype: displayItemPerformanceGridData, //json
url:'/DISMGMT/StandardProxy/displayItemPerformanceService?userRole='+userRole+
'&userName='+userName+'&duration='+displayDuration+'&userId='+userId,
datatype: 'json',
colNames: ["CM","Display Location","Display Name","Item","Item Description",
"Store","DC","Date","Type","Promo Retail","Reg. Retail 50" "Units",
"Sales $", "Profit $"],
// $("#load_navGrid").html("Loading...").show();
colModel: [
{name:"cmName",index:"cmName",classes:"metric",width:130,resizable:true,
align:"left"},
{name:"displayLocation",index:"displayLocation",width:80,align: "left"},
{name:"displayName",index:"displayName",width:225,align:"left"},
{name:"item",index:"item",sorttype:"int",width:60,align:"left"},
{name:"itemDescription",index:"itemDescription",width:230,align:"left"},
{name:"store",index:"store",sorttype:"int",width: 70,align: "right"//,
//unformat : spaceFormatter
},
{name: "dc", index: "dc", sorttype: "int",width: 60,align: "right"//,
//unformat : spaceFormatter
},
{name:"date",index:"date",sorttype:"date",datefmt:"mm-dd-yy",width:80,
align: "left"},
{name: "type",index: "type",width: 45,align: "left"},
{name: "price",index: "price",width: 70,align: "left"},
{name: "regRetail",index: "regRetail",width: 70,align: "left"},
{name:"units",index:"units",sorttype:"int",width:45,align:"right",
unformat : spaceFormatter},
{name:"sales",index:"sales",sorttype:"int",width:45,align:"right",
unformat : spaceFormatter},
{name:"profit1",index:"profit1",sorttype:"int",width:40,align:"right",
unformat : spaceFormatter}
],
width: 982,
height: 137,
toolbar: [true, "top"],
viewrecords: true,
rowNum: 1500,
// gridview:true,
loadonce:true
});
請提示我如何提高jqGrid的性能
您是否也可以包含`spaceFormatter`和`metric` CSS的代碼。爲什麼你評論了'gridview:true`這一行?它應該提高性能。順便說一句,`align:「left」`設置是默認設置,可以從所有列定義中刪除。你能提供任何測試數據來填補網格嗎?如果將JSON數據保存在像test.json這樣的文本文件中,並將`url`值替換爲`test.json`,則可以在沒有服務器組件的情況下測試網格。 – Oleg 2010-12-07 12:04:26