【发布时间】:2016-07-15 06:57:52
【问题描述】:
我对 jqGrid 中的列使用了自定义格式化程序和取消格式化:
{name: 'STATUS', index: 'STATUS',width:145,align:'center',fixed:true, formatter:statusFormatter, unformat:statusUnFormatter}
格式化程序:
function statusFormatter(cellvalue, options, rowObject){
var icon = '';
var label = '<span class="label status-label">';
switch (cellvalue){
case 'Rejected': {
icon = '<i class="fa fa-times"></i>';
label = '<span class="label label-primary status-label">';break;}
case 'Approved': {
icon = '<i class="fa fa-check"></i>';
label = '<span class="label label-primary status-label">';break;}
default: break;
}
return label + icon+" " +cellvalue + '</span>';
}
取消格式化:
function statusUnFormatter(cellvalue, options, cell){
var html = '<div>' + cellvalue + '</div>';
html.find('i').removeClass();
html.find('span').removeClass();
return html.text();
}
表格如下所示: Column after formatted
当我使用 getrowdata() 时出现问题,它返回内容而不是单元格的原始值。 Result of alert()
onCellSelect: function(id, icol, cellcontent, e){
var status = $(this).getRowData(id).STATUS;
alert(status);
}
【问题讨论】: