valor-software / ng2-table

Simple table extension with sorting, filtering, paging... for Angular2 apps
http://valor-software.github.io/ng2-table/
MIT License
553 stars 335 forks source link

Http Async Promise doesn't draw the table until manually clicked #439

Open tosehee75 opened 7 years ago

tosehee75 commented 7 years ago

In below code, if I manually set the data, it displays the table correctly.

However, if I externalize the data with "Http" and promise, it doens't display the table until the user manually clicks someone on the table itself.

I am guessing the async is causing this issue, but I have no clue how to work around it..

this.data = [
  {
    'number': '000282882',
    'shipToName': 'Bill Gibson',
    'contractNumber': 'PO-12345634',
    'shipVia': 'UPS Ground',
    'shippingStatus': 'Shipped',
    'actualShipDate': '1/25/2017 12:00 PM',
    'updatedDate': '1/25/2017 12:00 PM',
    'currentStatus': 'Draft'
  },
  {
    'number': '000282882',
    'shipToName': 'Bill Gibson',
    'contractNumber': 'PO-12345634',
    'shipVia': 'UPS Ground',
    'shippingStatus': 'Shipped',
    'actualShipDate': '1/25/2017 12:00 PM',
    'updatedDate': '1/25/2017 12:00 PM',
    'currentStatus': 'Pending'
  }
];
this.length = this.data.length;
this.onChangeTable(this.config);

// this.orderService.getOrderListForTab(tab, this.columns, this.page, this.itemsPerPage).subscribe(res => {
//     this.data = res;
//     this.length = this.data.length;
//     this.onChangeTable(this.config);
//   });
tosehee75 commented 7 years ago

Never mind on this.

Changing the detection strategy from OnPush to default fixed the problem for me.

changeDetection: ChangeDetectionStrategy.Default,

stalinrangel commented 6 years ago

thanks tosehee75 i solved