Open vdoolla opened 7 years ago
Confirm. This one is reproducible.
Hi - Thank you for your response.
Yes I am still having the issue to set the activePage attribute. I am using the 0.5.2 version. Below is the code snippet of code how I am trying to set the activePage
mfRowsOnPage is working fine. Having issue with mfActivePage only. Please kindly let me know if you see any issue with my usage or do you have any work around to set the activePage.
We are seeing the same issue. Setting mfActivePage as shown above does not set the page as selected. Did anyone find a solution or work around for this?
Any workaround for setting activePage from component ?
pageSizeOptions: number[] = [5, 10, 50];
rowsOnPage: number = 5;
@ViewChild(DataTable) child: DataTable;
//import {DataTable} from "angular2-datatable";
setNewPage(activePage: number) {
//activePage: number, rowsOnPage: number
this.child.setPage(activePage, this.rowsOnPage);
}
@alienk1 - Thank you for sharing your solution but it is not working for me. Today I have tried your option with angular2-datatable: 0.5.2 and angular2-datatable: 0.6.0 verisons.
While calling this.child.setPage(this.currentActivePage,this.rowsOnPage); getting Exception Cannot read property 'setPage' of undefined.
As suggested above imported Datatable and placed @ViewChild attribute.
If the above solution is working for you could you please share the version numbers of both datatable and angular2/complier please.
after response.json() call we need to call below function this.child.setPage(activePage, this.rowsOnPage);
@hazielm - When I am calling this.child.setPage(this.currentActivePage,this.rowsOnPage); getting Exception Cannot read property 'setPage' of undefined. Is it working for you ?.. What is the version you are using?
"raw": "angular2-datatable@^0.6.0", "version": "0.6.0"
import { DataTable } from 'angular2-datatable'; @ViewChild(DataTable) child: DataTable; after importing run this command "ng build" response => { this.data = response.json(); console.log(this.data); this.child.setPage(this.activePage,this.rowsOnPage); this.showDetails = true; },
solution provided by @hazielm solved this problem for me.
@guneetsinghbhatia , @hazielm
It would be grateful if anyone give me some hints to resolve ViewChild undefined issue.
@hazielm working for me
i am still getting undefined in childDataTable. I configured as suggested by oosor commented on Aug 15, 2017 . still getting undefined while i printed in console during ngOnInt . I am bit confused where to place this.child.setPage(this.activePage,this.rowsOnPage)? Can anyone please help? I have placed it as blow: async getAllJobs() { if (!this.isAllDataFetched) { Helpers.setLoading(true); let tripData = await this._jobService.getCompletedJobs(); this.jobs = [...tripData];
this.setDriverAndVahicle();
this.sortJobArrayByTime();
Helpers.setLoading(false);
this.isAllDataFetched = true;
this.child.setPage(this.activePage, this.rowsOnPage);
return;
}
return;
}
thank you every one i have fixed the issue as suggested by @hazielm
Hello All, I am using angular2-datatable: ^0.5.2 with angular/cli 1.0.0-beta.31 version and trying to set the activepage as below
Even though I am passing a positive number value for mfActivePage is not setting the value to the component. As per my business requirements I have to set active page number. If anyone knows the resolution for this issue please kindly post your suggestions.