Prior implementation of grid assumed all fields were defined as properties of
the top object with no nesting. The update facilitates use of nested objects.
Signed-off-by: Adam King <rak(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.grid.js | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/ui/js/src/kimchi.grid.js b/ui/js/src/kimchi.grid.js
index e5892ff..340ff7a 100644
--- a/ui/js/src/kimchi.grid.js
+++ b/ui/js/src/kimchi.grid.js
@@ -166,8 +166,21 @@ kimchi.widget.Grid = function(params) {
$.each(data, function(i, row) {
var rowNode = $('<tr></tr>').appendTo(tbody);
$.each(fields, function(fi, field) {
- var fieldName = field['name'];
- var value = (row[fieldName]==null) ? '' : row[fieldName];
+ var fieldName = field['name'].split('.');
+ var tmpRow=row;
+ for(var i=0;tmpRow && i<fieldName.length;i++) {
+ tmpRow=tmpRow[fieldName[i]];
+ }
+ var value;
+ if (tmpRow==undefined) {
+ value='';
+ }
+ else if (Array.isArray(tmpRow)) {
+ value=tmpRow.toString();
+ }
+ else {
+ value=tmpRow;
+ }
$('<td><div class="cell-text-wrapper"' +
(field['makeTitle'] === true
? ' title="' + value + '"'
--
1.8.1.4