DEMO Code
var _scope = this;
this.logJqGrid = logTable.jqGrid({
datatype: "local",
colNames:
[
NextGen.Lang.DeviceLogGraph.tableHeader.date,
NextGen.Lang.DeviceLogGraph.tableHeader.value
],
colModel:[
{name:'timestamp',index:'timestamp', width:60, align:'center',formatter : this.dateFormatter},
{name:'value',index:'value', width:40, align:'center'}
],
autowidth: true,
height: 'auto',
hidegrid: false,
forceFit: true,
altRows : true,
emptyrecords: "Nothing to display",
// onSelectRow : function()
// {
// NextGen.Index.currentPage.onSelectRow(); // global object cuicle reference don't bring on memory leak
// }
/**
* The following code will bring on memory leak
* 1. onSelectRow : NextGen.Utils.scopeHandler( this.onSelectRow, this ) == (function(fn,scope){return function(){fn.call(scope);}})(fn,scope);
* 2. var scope = this; onSelectRow : function(){scope.onSelectRow();}
*
*/
onSelectRow : NextGen.Utils.scopeHandler( this.onSelectRow, this )
});
Issure code :
p, pin
$.fn.jqGrid = function(pin) { //pin is init config object
if (typeof pin == 'string') {
//var fn = $.fn.jqGrid[pin];
var fn = $.jgrid.getAccessor($.fn.jqGrid,pin);
if (!fn) {
throw ("jqGrid - No such method: " + pin);
}
var args = $.makeArray(arguments).slice(1);
return fn.apply(this,args);
}
return this.each( function() {
if(this.grid) {return;}
var p = $.extend(true,{
grouping : false,
ignoreCase : false,
cmTemplate : {},
idPrefix : ""
}, $.jgrid.defaults, pin || {});
init config info object pin's event handler will hold reference _scope ,and p has the same reference. _scope hold jqgrid return object ,it can access p/pin indirect, it bring on circularreference.
profile:
from snapshot ,we can find, two place hold memory can't free:
1. pin, init config object, it has a reference point onSelectRow
2. p, it has the copy of pin properties
resolve:
1. remove pin
p hold the copy of pin ,so pin is unavailable, we can remove it after copy the properties.
if(this.grid) {return;}
var p = $.extend(true,{
}, $.jgrid.defaults, pin || {});
pin = null; // remove pin
2. remove all properties of p in GridDestroy, just need to remove function properties
GridDestroy : function () {
return this.each(function(){
if ( this.grid ) {
if ( this.p.pager ) { // if not part of grid
$(this.p.pager).remove();
}
for(var key in this.p) // remove all properties of p
{
this.p[key] = null;
}
this.p = null;
try {
$("#gbox_"+$.jgrid.jqID(this.id)).remove();
} catch (_) {}
}
});
},
- 大小: 135.9 KB
分享到:
相关推荐
jquery.jqGrid-4.6.0(jquery表格插件).zip----------jqGrid4.6.0包,官网下载的,原封不动的在这里。 jqgrid_demo40-----可用的-使用方法请查看README文件.rar-----------经我修改过的demo40,官网上面demo40下载...
jqGrid 学习 原理 2 jqGrid 学习之 皮肤 2 jqGrid 学习 2 jQuery 学习之:jqGrid 表格插件 参数配置 4 jqGrid 学习 自定义搜索 14 jqGrid 学习 搜索工具栏 16 jqGrid 学习 搜索 17 jqGrid 学习 自定义格式化类型 19 ...
jqgrid
jquery.jqGrid-4.8.2(jquery表格插件).zip----------jqGrid4.8.2包,官网下载的,原封不动的在这里。 jqgrid_demo40-----可用的-使用方法请查看README文件. jqgrid_3.6.5_API_en.chm------附加放在这里的其它资料...
jqgrid中文文档API,使用JQGRID
JqGrid插件+JqGridDemo+JqGrid主题,自己项目里引入的文件
JqGrid中文API文档,包含了基础的JqGrid控件的属性方法事件等,有如何使用JqGrid的Demo.
jquery.jqgrid
jqGrid5.5 学习
jQgrid+demo
jqgrid4.0jqgrid4.0jqgrid4.0jqgrid4.0jqgrid4.0jqgrid4.0jqgrid4.0jqgrid4.0jqgrid4.0jqgrid4.0
jqgrid实现分组显示和统计的功能,jqgrid实现分组显示和统计
jqGrid_API中文
jqGrid demo
jqGrid 最新版 3.7.2 离线帮助手册,方便各位查看 Installing jqGrid Before you begin System Requirements Download jqGrid Change Log How to Install How it Works My First Grid Basic Grid Conventions ...
jqgrid 的帮助文档 jqGrid属性
jqGrid 中的锁定固定的列并且关于jqGrid 中的一些排序的实现细节
jqgrid jqgrid 增删查改 添加toolbar 不保存到数据库 artdialog 弹出框
jqGrid详解及高级应用
jquery jqgrid 参数详