很多时候,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, sortable: true, align: ‘left‘, process: (function (ob, hdl) { return function (celDiv, id) { hdl(ob, celDiv, id); }; }(ob, ob.editDescription)) }, { display: deviceNumber, name: ‘deviceNumber‘, width: 110, sortable: true, align: ‘left‘ }, { display: del, name: ‘del‘, width: 25, sortable: true, align: ‘left‘, process: (function (ob, hdl) { return function (celDiv, id) { hdl(ob, celDiv, id); }; }(ob, ob.remove)) } ] } ); $.ajaxSetup({ cache: false }); },
原文地址:http://blog.csdn.net/csfreebird/article/details/39034571