handsontable / ngHandsontable

Official AngularJS directive for Handsontable
http://handsontable.github.io/ngHandsontable/
MIT License
433 stars 159 forks source link

How Datarows internally work? #233

Closed akashbiz closed 6 years ago

akashbiz commented 6 years ago

Hi @warpech @AMBudnik , If I use following input to datarows


Tests = [
        {
            'Name' : 'Test1',
            'id' : 1,
            'Comps': [
                {
                    'Name': 'Comp1',
                    'Result': true,
                    'Available' : true
                }
            ]
        },
        {
            'Name' : 'Test2',
            'id' : 2,
            'Comps': [
                {
                    'Name': 'Comp1',
                    'Result': true,
                    'Available' : true
                }
            ]
        }
    ]

then in my code as below:

<hot-table settings="{rowHeaders: true, colHeaders: true, manualRowMove: true, manualColumnMove: true, copyPaste: false, fixedColumnsLeft: 1}"
           datarows="resp.Tests">
    <hot-column data="Name" title="'Test Names'" type="grayedOut" read-only></hot-column>
    <hot-column ng-repeat="obj in Comps" data="obj.Result" title="obj.Name"></hot-column>
</hot-table>

I am not able to access Comps in second though I can access Name in first . Don't know why is it so? also how can I access a particular test at second if it depends on value of test provided at datarows. Can I get index or current test for which table is getting generated like we get the obj in ng-repeat.

Hoping for a quick response.

AMBudnik commented 6 years ago

Hi @akashbiz

If there are more than 2 levels of nesting Handsontable won't display the data.

Here we have your tests (in vanilla, but the logic is the same) http://jsfiddle.net/jLjyvuet/ if you would like to use (tests[0].Comps[0].Name for 3rd column you would need to parse the data into 2d array or array of objects first.

akashbiz commented 6 years ago

Hi @AMBudnik , Thanks for response but I did not understand how you specified columns(in vanilla). Also can please elaborate how to parse the data into 2d array or array of object first?

Is there any way we can get reference of current test while evaluating its columns or any index?

akashbiz commented 6 years ago

I have also tried to specify data-schema, I thought it may help handson table to parse data in given format but the ng-repeat on Comps array doesn't work only. ng-repeat on other external array ( outside of this tests array ) works and we can get column headers get printed but data binding of those again doesn't work.

<hot-column ng-repeat="obj in resp.Comps" data="obj.Result" title="obj.Name"></hot-column>

in this title field accept obj.Name and display it as col-header but the obj.Result don't display anything.

@AMBudnik Can you share your skype id so that we can discuss it on chat?

akashbiz commented 6 years ago

If there are more than 2 levels of nesting Handsontable won't display the data.

To your point @AMBudnik , in demo name.first is display but just because it is an array in stead of object it doesn't accept that format and doesn't process an array. Do you think we can overcome this limitation by a minor changes in code?

AMBudnik commented 6 years ago

I will ask our developer for help. Tomorrow or a day after I should get some feedback.

akashbiz commented 6 years ago

Thanks @AMBudnik, will be waiting for update from developers.

AMBudnik commented 6 years ago

Hi @akashbiz

Unfortunately, Handsontable does not support this data structure. Your Comps would need to be an object, not an array of objects. We have tried to find a workaround for the issue but none of them was successful.

akashbiz commented 6 years ago

Ok @AMBudnik , Thanks for your support and time to try and respond back. I will look for some other solution now. Thanks & Regards, Akash.

AMBudnik commented 6 years ago

Oh, and here's a demo http://jsfiddle.net/vzay1jyd/ that shows the table when we change the array of objects to an object

akashbiz commented 6 years ago

Oh, and here's a demo http://jsfiddle.net/vzay1jyd/ that shows the table when we change the array of objects to an object

This work in case we have only one comp in each test, but there can be more than one comp in each test. So Comps needs to be an array.

AMBudnik commented 6 years ago

Yes, I am sure that the array is needed but there is no way (currently) to load this data. Sorry.

akashbiz commented 6 years ago

That's ok @AMBudnik, I will look for some other solution. Thanks for your help, support and time.