mvc index 用table显示内容,文字过长时用......表示

此行是显示文字的内容,加载时自动调用commonSubstring()函数判断

{
title: '点评', field: 'commonent', 180, resizable: true,
formatter: function (val, row)
{
var strcommon = "";
strcommon += "<font>" + commonSubstring(row.commonent) + "</font>";
return strcommon;
}
},

function commonSubstring(str) {
if (str != null) {
if (str.length > 20) {
var sub = str.substring(0, 20) + "......";
return sub;
} else {
return str;
}
}
if (str == null) {
return "";
}
}

原文地址:https://www.cnblogs.com/zxk3113/p/4653606.html