0

I am currently working with ngx-datatable.

I collect data after subscribe and store it in dataRows:

this.dataRows = res.data.items;

which then passed to ngx-datatable

<ngx-datatable
            class="bootstrap"
            [rows]="dataRows"
            [columns]="dataColumns"
            [columnMode]="'force'"
            [headerHeight]="50"
            [selectionType]="'single'"
            [selected]="selected"
            (select)="recordSelected()"
            [messages]="{emptyMessage: 'Data not found!', totalMessage: 'total'}"
            [count]="totalItems"
            >
        </ngx-datatable>

My problem is if dataRows is empty, it shows empty Message but I receive error message too

core.js:1350 ERROR TypeError: Cannot convert undefined or null to object
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
nas
  • 2,289
  • 5
  • 32
  • 67

2 Answers2

2

There is nothing wrong with your sintax, you have used it as in manual:

[messages]="{emptyMessage: 'There are no records...'}"

As @suraz suggested, check for other possible errors

Gie
  • 222
  • 3
  • 5
0

check by using if condition.. for example if( data !== null){

this.dataRows = data;

}

suraz
  • 33
  • 9