flexGrid.columnHeaders.setCellData

Posted by: bmakhlin on 7 September 2018, 8:29 am EST

    • Post Options:
    • Link

    Posted 7 September 2018, 8:29 am EST

    Hi,

    I am getting error below trying to set flex grid header information:

    ERROR TypeError: Cannot read property ‘_hash’ of undefined

    at e.setCellData (wijmo.grid.js:13)

    In my code I insert row in columnHeaders and then call setCellData as below

    this.flexGrid.columnHeaders.rows.insert(0, new Row());

    this.flexGrid.columnHeaders.setCellData(0, 0, ‘user’);

    What could be the reason I get this error?

    What maybe unique in my code is that I need dynamically bind grid columns because columns are determined by number rows returned by the http endpoint.

    I have a parent component and a grid child component. Grid component has columns as @Input. Parent component binds columns using ‘async’ pipe in its template.

    When parent component makes http call and process response in its subscribe it calls next(columns) to bind columns with the grid component.

    The following code is executed on ngOnChanges in the grid component.

    this.flexGrid.columnHeaders.rows.insert(0, new Row());

    this.flexGrid.columnHeaders.setCellData(0, 0, ‘user’);

    Grid component on ngOnChanges binds grid with columns.

    I suspect this error is result of dynamic binding columns to the grid initiated by asynchronous endpoint call.

    thank you

  • Posted 9 September 2018, 6:15 pm EST

    Hi,

    As you already figured out the problem is arising because columns are not generated at the time when setCellData() is called.

    One neat solution for this type of requirement would be to define dataItem for the newly inserted row. This will ensure that proper data is displayed in the row when the columns become available.

    Please refer to the following sample which implements the same:

    https://stackblitz.com/edit/angular-rqqrjj?file=app%2Fgrid%2Fgrid.component.ts

    Regards

    Sharad

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels