Topic: Datatable Footer
stokkup2313 priority asked 2 years ago
Expected behavior
when i filter the data, i need to be able to retrieve the updated json. my table source data is set (example): this.datasource = [ {id: 314, owner_id: 307, client_id: 307, brand: "SoCal", product_name: "SC3000",cost:1},{id: 315, owner_id: 307, client_id: 307, brand: "SoCal", product_name: "SC3000",cost: 4},{id: 316, owner_id: 309, client_id: 307, brand: "SoCal", product_name: "SC3000",cost: 5},{id: 317, owner_id: 304, client_id: 307, brand: "SoCal", product_name: "SC3000",cost: 6}]
If i filter by owner_id and value 307, my data shows only 2 rows. how can i retrieve the updated datasource json of it (which contains something like this): [ {id: 314, owner_id: 307, client_id: 307, brand: "SoCal", product_name: "SC3000",cost:1},{id: 315, owner_id: 307, client_id: 307, brand: "SoCal", product_name: "SC3000",cost: 4}
? The reason i need this update data source is so i can have a method that will add the cost field and display in the footer .
Is there a specific variable that contains the filtered datasource?
Arkadiusz Idzikowski staff answered 2 years ago
@stokkup2313 Filtered data is the data
array returned by the mdbTable
directive (the one you use in ngFor
to generate table rows). If you use the data table with a search example from our example, then you can add a console.log to see that this value is changing when you use search method:
search(event: Event): void {
const searchTerm = (event.target as HTMLInputElement).value;
this.table.search(searchTerm);
console.log('filtered data', this.table.data);
}
stokkup2313 priority commented 2 years ago
@Arkadiusz Idzikowski this works now the only thing i notice, is that if i have pagination: this.table.data returns only the page that i am on. How do i ensure that it returns everything?
stokkup2313 priority commented 2 years ago
just to give you some background, I am trying to pass this to my export to excel method that i created and all i need is for all the data to be in there (the table can still be paginated just need pass the complete filtered to my method.
Arkadiusz Idzikowski staff commented 2 years ago
@stokkup2313 I'm afraid it is not possible to get all the data in this case because the component returns only the data that is displayed in the table.
I added a task for that and we will check if we can add an output event that will be helpful for such a use case.
stokkup2313 priority commented 2 years ago
@Arkadiusz Idzikowski then is it possible to have 'ALL' as part of the pagination list?
Arkadiusz Idzikowski staff commented 2 years ago
@stokkup2313 This feature is already on our to-do list but has not been implemented yet.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Angular
- MDB Version: MDB5 2.1.0
- Device: Desktop
- Browser: Chrome
- OS: MacOS
- Provided sample code: Yes
- Provided link: No