JqGrid在行中自定义自己的东西

时间:2023-12-23 16:38:32
 $.fn.fmatter.actions = function(cellval, opts) {
function baseOption(obj) {
return {
url: obj.url || '',
icon: obj.icon || '',
text: obj.text || '',
message: obj.message || '',
func: obj.func || ''
}
} function getUrl(url, id) {
return url.indexOf('?') > 0 ? url + "&id=" + id : url + "?id=" + id;
}
var op = {
keys: false,
editbutton: true,
delbutton: true,
editformbutton: false,
viewformbutton: false
},
rowid = opts.rowId,
str = "",
ocl;
if (opts.colModel.formatoptions !== undefined) {
op = $.extend(op, opts.colModel.formatoptions);
}
if (rowid === undefined || $.fmatter.isEmpty(rowid)) {
return "";
}
if (op.custombutton) {
for (var i = 0; i < op.custombutton.length; i++) {
var customoption = baseOption(op.custombutton[i]);
var url = getUrl(customoption.url, rowid);
console.log(customoption);
if (customoption.func != '') {
ocl = "id='jViewButton_" + rowid + "' onclick=" + customoption.func + "(" + rowid + ",this); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); ";
} else {
ocl = "id='jViewButton_" + rowid + "' onclick=jqGridDialog('" + url + "','" + customoption.message + "'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); ";
} str += "<div title='" + customoption.text + "' style='float:left;cursor:pointer;margin-right:5px;' class='ui-pg-div ui-inline-edit' " + ocl + "><span class='ui-icon " + customoption.icon + "'></span></div>";
}
}
return "<div style='margin-left:8px;'>" + str + "</div>";
};
源代码改的