ng2-table icon indicating copy to clipboard operation
ng2-table copied to clipboard

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

Open tosehee75 opened this issue 8 years ago • 2 comments

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 avatar Feb 09 '17 18:02 tosehee75

Never mind on this.

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

changeDetection: ChangeDetectionStrategy.Default,

tosehee75 avatar Feb 09 '17 21:02 tosehee75

thanks tosehee75 i solved

stalinrangel avatar Oct 29 '17 19:10 stalinrangel