Fixed #555 - DataTable crashes with a "Cannot read property 'xxx' of null" for nested objects

pull/599/head
Cagatay Civici 2020-10-22 12:13:48 +03:00
parent 074538ac94
commit 30daa63a58
1 changed files with 22 additions and 17 deletions

View File

@ -58,27 +58,32 @@ export default class ObjectUtils {
}
static resolveFieldData(data, field) {
if (typeof field === 'function') {
return field(data);
}
else {
if (data && field) {
if (field.indexOf('.') === -1) {
return data[field];
}
else {
let fields = field.split('.');
let value = data;
for (var i = 0, len = fields.length; i < len; ++i) {
value = value[fields[i]];
}
return value;
}
if (data && field) {
if (this.isFunction(field)) {
return field(data);
}
else if(field.indexOf('.') === -1) {
return data[field];
}
else {
return null;
let fields = field.split('.');
let value = data;
for(var i = 0, len = fields.length; i < len; ++i) {
if (value == null) {
return null;
}
value = value[fields[i]];
}
return value;
}
}
else {
return null;
}
}
static isFunction(obj) {
return !!(obj && obj.constructor && obj.call && obj.apply);
}
static filter(value, fields, filterValue) {