树表格支持多层级访问

master
RuoYi 5 years ago committed by Limy
parent dc58b164bf
commit e3bcd9aa54

@ -335,13 +335,13 @@
} }
// 增加formatter渲染 // 增加formatter渲染
if (column.formatter) { if (column.formatter) {
$td.html(column.formatter.call(this, item[column.field], item, index)); $td.html(column.formatter.call(this, getItemField(item, column.field), item, index));
} else { } else {
if(options.showTitle){ if(options.showTitle){
// 只在字段没有formatter时才添加title属性 // 只在字段没有formatter时才添加title属性
$td.attr("title",item[column.field]); $td.attr("title",item[column.field]);
} }
$td.text(item[column.field]); $td.text(getItemField(item, column.field));
} }
if (options.expandColumn == index) { if (options.expandColumn == index) {
if (!isP) { if (!isP) {
@ -583,6 +583,19 @@
$input.prop("checked", ''); $input.prop("checked", '');
} }
} }
// ruoyi 解析数据,支持多层级访问
var getItemField = function (item, field) {
var value = item;
if (typeof field !== 'string' || item.hasOwnProperty(field)) {
return item[field];
}
var props = field.split('.');
for (var p in props) {
value = value && value[props[p]];
}
return value;
};
// 初始化 // 初始化
init(); init();
return target; return target;

Loading…
Cancel
Save