Handle nested JSON correctly in SlickGrid. Fixes #1713. Fixes #1404

This commit is contained in:
Dave Page 2016-09-21 13:43:27 +01:00
parent 28ce31a022
commit 7a40171300
3 changed files with 31 additions and 1 deletions

View File

@ -230,6 +230,16 @@
var data = defaultValue = item[args.column.field];
if (typeof data === "object" && !Array.isArray(data)) {
data = JSON.stringify(data);
} else if (Array.isArray(data)) {
var temp = [];
$.each(data, function(i, val) {
if (typeof val === "object") {
temp.push(JSON.stringify(val));
} else {
temp.push(val)
}
});
data = "[" + temp.join() + "]";
}
$input.val(data);
$input.select();
@ -466,6 +476,16 @@
var data = defaultValue = item[args.column.field];
if (typeof data === "object" && !Array.isArray(data)) {
data = JSON.stringify(data);
} else if (Array.isArray(data)) {
var temp = [];
$.each(data, function(i, val) {
if (typeof val === "object") {
temp.push(JSON.stringify(val));
} else {
temp.push(val)
}
});
data = "[" + temp.join() + "]";
}
$input.val(data);
$input.select();

View File

@ -24,6 +24,16 @@
// Stringify only if it's json object
if (typeof value === "object" && !Array.isArray(value)) {
return JSON.stringify(value);
} else if (Array.isArray(value)) {
var temp = [];
$.each(value, function(i, val) {
if (typeof val === "object") {
temp.push(JSON.stringify(val));
} else {
temp.push(val)
}
});
return "[" + temp.join() + "]"
} else {
return value;
}

View File

@ -1790,7 +1790,7 @@ define(
*/
var explain_data_array = [];
if(
data.result && data.result.length > 1 &&
data.result && data.result.length >= 1 &&
data.result[0] && data.result[0].hasOwnProperty(
'QUERY PLAN'
) && _.isObject(data.result[0]['QUERY PLAN'])