【发布时间】:2011-03-17 20:14:49
【问题描述】:
我在客户端上将 jqgrid 用于金融 Web 应用程序,其中行会非常频繁地添加和/或更新(每隔几毫秒)。 最大行数始终保持在 80 以下。 数据通过彗星推送到网络(反向ajax) 当数据进来时,应用以下代码
更新 jqgrid 是这样定义的:
jQuery(selector).jqGrid(
{
datatype: 'local',
localReader: {
id: "id"
},
colNames: ["id","price","volume","time"],
colModel: [ {name:'id', width:60},
{name:'price', width:80,
align:"right",sorttype:"float"},
{name:'volume', width:100},
{name:'time',index:'amount', width:80}
],
sortname: '',
sortorder: 'desc',
height:'100%',
rowNum: 80,
viewrecords: true,
loadonce: true
});
........................
_updateGrid: function (handle, args) {
var updated = args.data;
var current = handle.jqGrid('getRowData', updated.id);
if (typeof current.id == 'undefined' || current.id == null
|| current.id == "") {
current = updated;
var itWorks = handle.addRowData(updated.id, current);
}
else {
handle.jqGrid('setRowData', updated.id,
{
id: updated.id
, price: updated.price
, volume: updated.volume
, time: updated.time
});
}
handle.sortGrid('price', false, 'desc');
}
现在性能非常糟糕,以至于firefox弹出一条错误消息要求停止脚本。
我正在考虑切换网格小部件,但在此之前我想看看其他开发人员是否有任何可以解决问题的想法。
【问题讨论】:
标签: javascript performance sorting jqgrid client-side