定义一个函数
function filterChar(cellvalue, options, rowObject) {
if (cellvalue != "" && cellvalue != null && cellvalue != undefined) {
cellvalue = cellvalue.replace(/[<]/g, "<").replace(/[>]/g, ">").replace(/\r\n/g,"").replace(/\n/g,"").replace(/\s/g,"").replace(/[\"]/g, """).replace(/[\']/g, "'").replace(/[\r\n]/g, '<br>');
}
return cellvalue;
}
调用的地方
common.getRenderer("sys_message_form").extends({
jqGrid: null,
rownumbers: true,
colNames: ["ID", 'xxx', 'xxxx '],
colModel: [
{name: "id", hidden: true},
{name: 'xxxx', width: 55},
{
name: 'xxxx', classes: "text-ellipsis", width: 100,
formatter: 'string',
formatter: function (cellvalue, options, rowObj) {
return filterChar(cellvalue, options, rowObj);
}
}