showmytable:function(a){
var data={
url:'',
method:'get',
dataType: "json",
striped: true,
cache:false,
singleSelect: false,
pagination: true,
pageNumber:1,
pageSize: 10,
pageList: [10, 25, 50, 100],
columns: [{
field: 'id',
title: '序号'
}, {
field: 'agentno',
title: '业务员编号'
}, {
field: 'agentname',
title: '业务员姓名'
}, {
field: 'time',
title: '时间'
},{
field: 'mark',
title: '备注'
}]
}
};
由于字段mark的值可能过长,会影响到table的布局,需要对其进行攫取处理
我采用了formatter函数,对当前列的数据进行格式化操作,field字段必须与服务器端返回的字段对应才会显示出数据,value:代表当前单元格中的值,使用return 返回的value显示在单元格中;return返回自定义的span标签,也可以自定义一个div弹出层,代码如下
showmytable:function(a){
var data={
url:'',
method:'get',
dataType: "json",
striped: true,
cache:false,
singleSelect: false,
pagination: true,
pageNumber:1,
pageSize: 10,
pageList: [10, 25, 50, 100],
columns: [{
field: 'id',
title: '序号'
}, {
field: 'agentno',
title: '业务员编号'
}, {
field: 'agentname',
title: '业务员姓名'
}, {
field: 'time',
title: '时间'
},{
field: 'mark',
title: '备注',
formatter:function(value,row,index){
//此处对value值做判断,不然value为空就会报错
value=value?value:'';
var length=value.length;
if(length&&length>7){
elngth=7;
}
return"<span title ='"+value+"'>"+value.substring(0,length)+"</span>"
}
}
}]
}
};