加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flexigrid的处理函数使用闭包传递this对象

发布时间:2020-12-15 03:39:05 所属栏目:百科 来源:网络整理
导读:很多时候,process函数都需要获得this对象,然后调用一些方法。 下面举个例子: config : function (groupName,description,deviceNumber,del) { var ob = this; $("#groups").flexigrid({ dataType: 'json',width: 870,height: 300,colModel : [{ display: g

很多时候,process函数都需要获得this对象,然后调用一些方法。

下面举个例子:

	config : function (groupName,description,deviceNumber,del) {
	    var ob = this;
	    $("#groups").flexigrid(
		{
		    dataType: 'json',width: 870,height: 300,colModel : [
			{
			    display: groupName,name: 'groupName',width: 200,sortable: true,align: 'left',process: (function (ob,hdl) {
				return function (celDiv,id) {
				    hdl(ob,celDiv,id);
				};
			    }(ob,ob.editName))
			},{
			    display: description,name: 'description',width: 469,ob.editDescription))
			},{
			    display: deviceNumber,name: 'deviceNumber',width: 110,align: 'left'
			},{
			    display: del,name: 'del',width: 25,ob.remove))
			}
		    ]
		}
	    );
	    $.ajaxSetup({ cache: false });
	},
这样就能完美的解决无法传额外参数的问题。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读