easyui-datagrid列宽自动填充
function loadSuccess(data){
var rows = data.rows;// 获取行数据
// 获取动态行
var fields = $(“#dataTable”).datagrid(‘getColumnFields’);
// 获取固定行
var opts = $(‘#dataTable’).datagrid(‘getColumnFields’, true);
// 动态行该列最大字符数
var columnMaxCharacter = new Array();
// 固定行该列最大字符数
var columnMaxCharacterOpt = new Array();
for (var i =0;i<rows.length; i++) {
for (var j = 0; j < opts.length; j++) {
var s = rows[i][opts[j]];
if (typeof columnMaxCharacterOpt[opts[j]] == “undefined”) {
columnMaxCharacterOpt[opts[j]] = 0;
}
if ( typeof s != “undefined” && s.length > columnMaxCharacterOpt[opts[j]]) {
columnMaxCharacterOpt[opts[j]] = s.length;
}
}
for (var j = 0; j < fields.length; j++) {
var s = rows[i][fields[j]];
if (typeof columnMaxCharacter[fields[j]] == “undefined”) {
columnMaxCharacter[fields[j]] = 0;
}
if ( typeof s != “undefined” && s.length > columnMaxCharacter[fields[j]]) {
columnMaxCharacter[fields[j]] = s.length;
}
}
}
// 系统字体大小
var fontSize = 14;
for (var j = 0; j < opts.length; j++) {
var textLength = columnMaxCharacterOpt[opts[j]];
if (typeof textLength != “undefined” && textLength >= 10) {
var width = fontSizetextLength;
$(“td[field='”+opts[j]+“'] div”).width(width);
}
}
for (var j = 1; j < fields.length; j++) {
var textLength = columnMaxCharacter[fields[j]];
if (typeof textLength != “undefined” && textLength >= 10) {
var width = fontSizetextLength;
$(“td[field='”+fields[j]+“'] div”).width(width);
}
}
}
状态 | 编码 | 名称 |
---|---|---|
注册资金(万元) | 供应商等级 | 申请时间 |