Here's my code
Component:
public async getDataTable() {
await this.detail.execute({
skip: 0,
take: 10,
action: {
currentPage: 1,
},
});
}
public async getDataTablesStateExchange(state: DataStateChangeEventArgs) {
let details = await this.detail.execute(state);
}
Service:
public async execute(state: any, filter?: any): Promise<any> {
let data = await this.getDataTable(state, filter);
super.next(data);
}
public async getDataTable(state: DataStateChangeEventArgs, filter?: any): Promise<DataStateChangeEventArgs> {
let { action }: any = state;
let current_page: number = action?.currentPage ? action?.currentPage : 1;
if (state.take == 1) {
current_page = 0;
}
let data = await this.baseService
.get('api/detail', {
...filter,
page: current_page,
page_size: state.take,
})
.toPromise();
let detail: PaginationModel<detail> = data as PaginationModel<detail>;
let dataResult: DataResult = {
count: detail.total,
result: detail.data,
};
return dataResult as any;
}