1. jqgrid中加入formatter

{index:'authenticationFunction',name:'authenticationFunction',align:"center",title:false,formatter:StrLenFormat},

 

2.引入包

<script type="text/javascript" src="<%=path %>/quality/js/strgride.js"></script>

 

3.js文件如下

function StrLenFormat(cellvalue, options, rowObject){

  var oldstrlen=cellvalue.length;
 
  var newstr="";
     
   if(oldstrlen>10){
     newstr=cellvalue.substring(0,10)+"...";
    
     newstr="<div title='"+cellvalue+"'>"+newstr+"</div>";
   }else{
     newstr=cellvalue;
   }
  return newstr;
}