Open wjllz opened 2 years ago
mini_patch, maybe buggy.... but it works... but I believe it should be buggy code....
var rows = this.data.map(function (obj, index) {
var tr = DOMHelper.createElement('tr')
var firstTd = DOMHelper.createElement('td', typeof index);
firstTd.appendChild(new JSONGrid(index).generateDOM());
tr.appendChild(firstTd);
// [+] add by 18f
if(typeof obj != 'object'){
var td = DOMHelper.createElement('td', typeof obj, 'table-wrapper');
td.appendChild(new JSONGrid(obj).generateDOM());
tr.appendChild(td);
}
// [+] end patch
keys.forEach(function (key, keyIdx) {
var td = DOMHelper.createElement('td', typeof obj, 'table-wrapper');
var value = (obj[key] === undefined || obj[key] === null)
? '' + obj[key]
: obj[key]
;
td.appendChild(new JSONGrid(value).generateDOM());
tr.appendChild(td);
});
return tr;
});
The patch code which I think is bug, it is because that:
I assume keys always be empty set when obj is not a object, but is it always true? If not, critical bug will happened :(
The original writer write this code:
When we call processArray, the element of the array always be a object, so it can't deal with [1, 2, 3, 4, 5]. in this way, keys will be empty set....
And I think there are another bug:
"date": ["111", "222", "333"],
use https://www.araujoigor.com/en/json-grid u will found the resolve result is wrong...
make my patch be this:
// [+] add by 18f
if(typeof obj != 'object'){
var td = DOMHelper.createElement('td', typeof obj, 'table-wrapper');
td.appendChild(new JSONGrid(obj).generateDOM());
tr.appendChild(td);
return tr;
}
// [+] end patch
get this result:
Still wrong... but now it is easy read....
hey, this seems can't convert this json rightly: