首页 > 代码库 > JqGrid在行中自定义自己的东西

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

 1 $.fn.fmatter.actions = function(cellval, opts) {
 2     function baseOption(obj) {
 3         return {
 4             url: obj.url || ‘‘,
 5             icon: obj.icon || ‘‘,
 6             text: obj.text || ‘‘,
 7             message: obj.message || ‘‘,
 8             func: obj.func || ‘‘
 9         }
10     }
11 
12     function getUrl(url, id) {
13         return url.indexOf(‘?‘) > 0 ? url + "&id=" + id : url + "?id=" + id;
14     }
15     var op = {
16             keys: false,
17             editbutton: true,
18             delbutton: true,
19             editformbutton: false,
20             viewformbutton: false
21         },
22         rowid = opts.rowId,
23         str = "",
24         ocl;
25     if (opts.colModel.formatoptions !== undefined) {
26         op = $.extend(op, opts.colModel.formatoptions);
27     }
28     if (rowid === undefined || $.fmatter.isEmpty(rowid)) {
29         return "";
30     }
31     if (op.custombutton) {
32         for (var i = 0; i < op.custombutton.length; i++) {
33             var customoption = baseOption(op.custombutton[i]);
34             var url = getUrl(customoption.url, rowid);
35             console.log(customoption);
36             if (customoption.func != ‘‘) {
37                 ocl = "id=‘jViewButton_" + rowid + "‘ onclick=" + customoption.func + "(" + rowid + ",this); onm ouseover=jQuery(this).addClass(‘ui-state-hover‘); onm ouseout=jQuery(this).removeClass(‘ui-state-hover‘);  ";
38             } else {
39                 ocl = "id=‘jViewButton_" + rowid + "‘ onclick=jqGridDialog(‘" + url + "‘,‘" + customoption.message + "‘); onm ouseover=jQuery(this).addClass(‘ui-state-hover‘); onm ouseout=jQuery(this).removeClass(‘ui-state-hover‘);  ";
40             }
41 
42             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>";
43         }
44     }
45     return "<div style=‘margin-left:8px;‘>" + str + "</div>";
46 };
源代码改的

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