0

I have a table in qooxdoo that shows some data, but this data is a little bit different because has embedded subdocuments:

[
    {
        simpleField: 1,
        mapSubDocField: {
            key1: 1,
            key2: 3
        }
    },
    {
        simpleField: 1,
        mapSubDocField: {
            key1: 1,
            key2: 3
        }
    },
    {
        simpleField: 1,
        mapSubDocField: {
            key1: 1,
            key2: 3
        }
    },
]

I've tried to do something like this but didn't work:

model.setColumns(   ['simpleFIeld', 'key1', 'key2'], 
            ['simpleFIeld', 'mapSubDocField.key1', 'mapSubDocField.key2']);

but didn't work, my field it's empty.

How may I do? thanks

EDIT: Currently in my model I've also added this script:

        var i = result.length;
        var item;
        var key;
        var subitem;
        var subkey;
        while(i--){
            item = result[i];
            for(key in item){
                if(Object.prototype.toString.call(item[key]) === '[object Object]'){
                    var subitem = item[key];
                    for(subkey in subitem){

                        item[key+'.'+subkey] = subitem[subkey];
                        delete item[key];
                    }
                }
            }
        }

and this will convert the object above to:

[
    {
        simpleField: 1,
        mapSubDocField.key1: 1,
        mapSubDocField.key2: 3
    },
    {
        simpleField: 1,
        mapSubDocField.key1: 1,
        mapSubDocField.key2: 3
    },
    {
        simpleField: 1,
        mapSubDocField.key1: 1,
        mapSubDocField.key2: 3
    }
]

But the question still maintains: exists a better way to do it? (maybe qooxdoo can manage it by itself)

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Totty.js
  • 15,563
  • 31
  • 103
  • 175

1 Answers1

0

The table is capable of showing data as a list of lists. If you have a hierarchical data structure, you might want to think about showing your data as tree. qooxdoo offers trees as well for data visualization. Maybe the TreeVirtual ist the right choice for you? If you want to stick to the table, its your responsibility to bring the data to a structure the table understands.

Martin Wittemann
  • 2,109
  • 1
  • 12
  • 14