[GH-DEV #880] nestedRows in angular doesnt recognize children

Tags: #<Tag:0x00007efc61a6d650> #<Tag:0x00007efc61a6d510>

Hello,

I’m using handsontable hot-table, in my Angular project, but i have some trouble with the detection of children element, my parent data are displayed in the table without problem but i have the following errors:
The Nested Rows plugin requires an Array of Objects as a dataset to be provided. The plugin has been disabled.

i dont understand why i have this errors because when i console.log the data for my table and i use it in jsfiddle with an exemple i found in a post with the same problem as me, it work perfectly, here is the jsfiddle: Handsontable example - JSFiddle - Code Playground

here is the declaration of my hot-table in my html file:

<hot-table class="type-1" [ngClass]="{'current-day': selectedDate === dateJ}" [data]="showDataType1"

           [colHeaders]="true" [nestedHeaders]="displayHour1" [rowHeaders]="rowFilteredVisualTypeHeader"

           [colWidths]="60"

           [rowHeaderWidth]="190" [rowHeights]="40" readOnly="true" [nestedRows]="true" [licenseKey]="licenseKey">

</hot-table>

and how i fill it in my typescript file:

this.rowFilteredTypeHeader.forEach((_, index) => {
    this.showDataType1.push(this.generateParent(this._dataType15m[index],0, 24,_));
  });

here are the other function which are used to fill my data:

private generateParent(array: number[], start: number, end: number, type: string): object {

const arrayData = array.slice(start, end);

const convertedData = this.convertArrayToObject(arrayData);

convertedData['__children'] = this.generateChildren(start, end, type);

return convertedData;

}


private generateChildren(start: number, end: number, type: string): object[] {

const children = [];

this.besWithGroup.forEach(be => {

  if (be.strikeGroupName === type) {

    const childData = this.convertArrayToObject(be.strikeValues.slice(start, end));

    children.push(childData);

  }

});

return children;

}


private convertArrayToObject(arrayData: number[]): object {

return arrayData.reduce((obj, value, index) => {

  obj[(index + 1).toString()] = value;

  return obj;

}, {});

}

Does someone have an idea why my table doesn’t recognize the children ?

I have found the solution for my problem, the plugin need the correct structure at the initialisation but my array was empty so it didnt work. you need to create the skeleton and then you can assign the correct data so the plugin doesn’t deactivate.

Can you please add this specification to the parent-child page because it is not described and it was really a hassle to find where was the problem.

Hi @alexisG

Thank you for sharing the issue report.

The issue should be gone once this bug is solved https://github.com/handsontable/handsontable/issues/7017.

I will inform you once we’re ready with the fix.