Closed alex-mazzariol closed 8 years ago
In case you haven't found a way, here is how i do it :
@ViewChild('dataTable') dataTable: DataTable;
public resetPagination() { this.dataTable.setPage(1, this.dataTable.rowsOnPage); }
<table width="1000" class="table table-hover" [mfData]="dataService.productList" #dataTable="mfDataTable" [mfRowsOnPage]="rowsOnPage" [mfActivePage]="activePage">
This works, thank you!
@lacroixdavid1 & @alex-mazzariol - From last 10 months I am struggling to set active page to the datatable Please review my above code snippet and let me know if you see any issues with usage of ViewChild. Any sort of help is really appreciable
@JavaCoder12 could you please reproduce in a plunker ill fix it for you. I see nothing wrong with your code its probably caused by where your method is called. Where do you call this method?
@JavaCoder12 Were you able to find a solution for your problem? I have the exact same problem => this.dataTable is undefined.
Scenario: I load a large dataset in the table (say 1000 rows), then the user switches to some non-first page (say page 10, pages have 15 elements), then another action in the page updates the dataset to a smaller one (say 50 elements) - there should be now 4 pages.
What happens is that the paginator does not show anymore, so the user can't switch back to page 1, and no rows are shown either - the UI seems broken.
Is there a way for me to set the page from the component, or a way to have the datatable go back to page 1 (or the mfActivePage)?