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

Table stop working after try to filter in the last page.

Open ghost opened this issue 10 years ago • 9 comments

This error happend when the total of results need less "pages" than the position for the actual page.

Steps to reproduce:

go to: http://valor-software.com/ng2-table/

In the example table, click on last button on the pagination menu

Go to filter input, type anything

ghost avatar Jun 09 '16 17:06 ghost

Same here, but clicking on any page other than "1". Tried in ffox & chrome.

gabrielg-dev avatar Jun 23 '16 18:06 gabrielg-dev

just click any page then use filter

hoangnguyenba avatar Aug 04 '16 08:08 hoangnguyenba

  1. clic "Last" (page navigation)
  2. in "filter" I wrote "aaa" (correctly dissapeared all rows)
  3. delete filter
  4. get next screen: screen

gabrielg-dev avatar Aug 04 '16 14:08 gabrielg-dev

Tracked this down to the pagination component of ng2-bootstrap. The exact error is:

ORIGINAL EXCEPTION: Expression has changed after it was checked. Previous value: ''. Current value: '[object Object],[object Object],[object Object],[object Object],[object Object]'

I "fixed" this by changing ng2-bootstrap/components/pagination/pagination.component.js:73 from this.selectPage(this.page); to this.writeValue(this.page);

Trying to figure out the details next.

philippkoelmel avatar Aug 24 '16 13:08 philippkoelmel

Same problem.. here.. but not necessarily last page.. It can happen at page 20 and you change the page size

wilfredmifsud avatar Oct 07 '16 09:10 wilfredmifsud

This error occurs when changes happen during change detection, specifically in the onChangeTable method from the demo code. A solution which fixes the problem is to explicitly notify about the change using ChangeDetectorRef.detectChanges() as the last statement of onChangeTable():

import { ChangeDetectorRef } from '@angular/core';

public constructor( private ref: ChangeDetectorRef ) { }

public onChangeTable(config: any, page: any = { page: this.page, itemsPerPage: this.itemsPerPage }): any {
    // Your logic to be executed on table change

    this.ref.detectChanges();
}

tudorciotlos avatar Nov 23 '16 11:11 tudorciotlos

It works !

wilfredmifsud avatar Nov 23 '16 13:11 wilfredmifsud

Cool!! It's working!

webcat12345 avatar Dec 28 '16 19:12 webcat12345

When I try the solution offered by @tudorciotlos on Nov 23, I get this exception:

error_handler.js:50 EXCEPTION: Uncaught (in promise): Error: Error in ./LogsComponent class LogsComponent - inline template:0:12 caused by: Cannot read property 'config' of undefined TypeError: Cannot read property 'config' of undefined at DebugAppView.View_LogsComponent0.detectChangesInternal (/AppModule/LogsComponent/component.ngfactory.js:330:36) at DebugAppView.AppView.detectChanges (http://localhost:4200/vendor.bundle.js:69471:14) at DebugAppView.detectChanges (http://localhost:4200/vendor.bundle.js:69666:44) at ViewRef_.detectChanges (http://localhost:4200/vendor.bundle.js:50278:20) at LogsComponent.onChangeTable (http://localhost:4200/main.bundle.js:1439:18) at SafeSubscriber._next (http://localhost:4200/main.bundle.js:1356:81) at SafeSubscriber.__tryOrSetError (http://localhost:4200/vendor.bundle.js:575:16) at SafeSubscriber.next (http://localhost:4200/vendor.bundle.js:517:27) at Subscriber._next (http://localhost:4200/vendor.bundle.js:468:26) at Subscriber.next (http://localhost:4200/vendor.bundle.js:432:18) at BehaviorSubject._subscribe (http://localhost:4200/vendor.bundle.js:54424:24) at BehaviorSubject.Observable.subscribe (http://localhost:4200/vendor.bundle.js:50:27) at Observable._subscribe (http://localhost:4200/vendor.bundle.js:108:28) at Observable.subscribe (http://localhost:4200/vendor.bundle.js:50:27) at new LogsComponent (http://localhost:4200/main.bundle.js:1356:47)ErrorHandler.handleError @

danny-swimmer avatar Jan 25 '17 15:01 danny-swimmer