ngHandsontable - column data index

With handsontable you can’t reference an index in the column data attribute (e.g. data: ‘ds_value.valueList[0].value’).

This kind of makes me sad because it means we’re left with dynamic objects being created client-side that won’t map to anything server-side. We allow the user to add new columns client-side so headers must be created from an object. I realize there are server-side solutions for dynamic objects but nothing that is clean and nothing that really maps to our current entities nicely.

Basically in order to solve this problem we have to mock up the handsontable “datarows” object as follows:
cell_objects: { cell_obj0: { value: ‘me!’, dirty: false }, cell_object1: { value: ‘you’, dirty: false }, etc… }

Heck, we can even skip indexes using this example. For instance if a cell value isn’t populated then we could have something that looks like the following:
cell_objects: { cell_obj0: { value: ‘me!’, dirty: false }, cell_object1: { value: ‘you’, dirty: false }, cell_object5: { value: ‘you’, dirty: false }, etc… }

We are using numbers in the cell_objects array because we can’t reference them any other way in the column object’s data attribute.

I mention all of this because if there was a way to reference indexes in the column “data” attribute then we wouldn’t have the problem. For instance the solution would look like the following:

    datasetCtrl.items = {
        columns: [{
            data: 'testCondition', title: 'Test Condition', readOnly: false
        },
        {
            data: 'cell_object[0].value'
        },
        {
            data: 'cell_object[1].value'
        },
        {
            data: 'cell_object[2].value'
        }],
        data: [{
            testCondition: 'Bob',
            id: '13',
            cell_object: [ { value: 'me!', dirty: false }, {}, { value: 'you', dirty: false } ]
        }]
    };

But this isn’t supported, which makes me a little sad. But, maybe there’s another way. If anyone here has any ideas please let me know! Maybe we can change our JSON a little bit to make this more server-side friendly.

Thanks,
Wes

Thank you for sharing your concerns Wes.

I will leave this issue opened for our developers to look at.

I just checked your topic and it really sounds like a good idea.
We should save it as a feature.
Thanks for sharing !

Hi @murph1329,

I think we’ve already support this kind of functionality. For accessing to an array index you should use dot notation not brackets notation. I’ve prepared demo at http://jsbin.com/mupenugaba/1/edit?html,js,output.

@budnix,

This worked perfectly!

Please consider this question resolved.

Thanks,
Wes.