Receiving sorted data from Material Table in Angular 6

Is it possible to retrieve the sorted data from a material table once the sorting has been applied? I noticed that there is a "filteredData" property in the table's datasource, but there doesn't seem to be a "sortedData" equivalent. My goal is to export the sorted data into a csv file while preserving all the applied sorts. Currently, I have been utilizing the MatSort functionality to sort columns individually within the table.

Answer №1

If you're looking to organize your data, consider using the sortData method available for both datasource.data and datasource.filteredData.

    dataSource.sortData(dataSource.filteredData,dataSource.sort);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to deploy static Angular builds for microservices on AWS S3 and ensure proper routing management?

Our Company's SAAS platform currently utilizes 7 to 10 Angular microservices, previously hosted on an EC2 engine with routing managed by Nginx. However, due to high costs associated with EC2, I have successfully migrated the website to a static websit ...

Different and Basic Designs for mat-table

Is there a way to customize the appearance of the material data table (mat-table) beyond the pre-built themes? I'm specifically interested in styles like table-striped, table-sm, or table-bordered from bootstrap 4. Is it possible to apply these style ...

Tips for avoiding Angular routing when clicking on a Bootstrap tab link

I'm working on creating a bootstrap tab, but I'm running into an issue. Every time I click on the tab links, angular seems to be handling its own routing and redirecting me to a different route. What I really want is for the tab content to open u ...

Uninitialized variables in Angular 4.0 causing Rxjs issues

Since the update to angular 4.0, I've been encountering errors with RxJs variables. While everything builds without any issues, when I try to load the page, I receive this error message: ERROR Error: Uncaught (in promise): TypeError: Cannot read pr ...

Angular date filter with no visual modifications

I need help with formatting a date. 2016-05-22 08:00:00 I have been trying to apply a filter, but it's not working as expected. <td>{{ event._source.event_date | date : "dd.MM.y"}}</td> Could someone please point out what I am missing ...

Is it possible for NgElse to target an imported component?

I'm in the process of creating a universal loading icon for my website. Here's what I have so far. <div> <p *ngIf="questionsLoaded; else loadingSign" > {{lstQuestions?.length}} question/s found </p> <ng-template #l ...

Having trouble retrieving my .scss bundle file from a different directory

I am trying to access my .scss file that imports all the other .scss files (they are all imported in styles.scss). Even though I have added the path to my angular cli file, the file is still not accessible and no styling is being applied to my html elemen ...

Retrieving JSON data in Angular 2

There are limited options available on SO, but it seems they are no longer viable. Angular 2 is constantly evolving... I am attempting to retrieve data from a JSON file in my project. The JSON file is named items.json. I am pondering if I can achieve th ...

Angular `CORS` Ailment

I am currently utilizing the MEAN stack (MongoDB, Express, Angular, and NodeJS). I have a basic function for fetching data from an external API as shown below: let api = 'https://thongtindoanhnghiep.co/api/city'; return this.http.get<any>(a ...

Getting the "No Connection with that ID" error from an ASP.NET application on IIS when using SignalR

My ASP.NET & Angular application was originally running smoothly on IIS on Windows Server 2019. However, upon moving the application to a different server, I encountered a recurring issue of receiving "No Connection with that ID" errors, causing some criti ...

Harnessing the power of config data within the forRoot function

I'm currently struggling with implementing the forRoot method in my application. Within my app, I am setting up the databaseService in the ngOnInit function of the AppComponent: this.databaseService.addDatabaseData(databaseData); I believe it would ...

Angular2 CanActivate error: undefined

I am looking to implement some restricted routes in my application. I have written a Guard following the documentation here, but I am trying to do it without using TypeScript: https://angular.io/docs/ts/latest/guide/router.html#!#guards However, I encount ...

What is the best way to declare and initialize a global variable in a TypeScript Node application?

When using Webpack: const WebpackConfig = { // ... plugins: [ new Webpack.DefinePlugin({ __IS_DEVELOPMENT_BUILDING_MODE__: isDevelopmentBuildingMode, __IS_TESTING_BUILDING_MODE__: isTestingBuildingMode, __IS_PRODUCTION_BUILDING_MO ...

Extract "Actual Components" (variables and functions) from a Rest API using Angular HttpClient

Recently, I encountered a similar issue to the one discussed in this post. Since the original question was posted in 2017, I was curious if there have been any advancements or simpler methods developed since then. One idea that came to mind was using an ...

Utilizing Angular 16 to Link Component Input with Parent Route Parameter

Picture a scenario where there is a component (some.component.ts) in Angular 16 that retrieves the value for its foo property from activeRoute, specifically from the parent route. Take a look at the code snippet below: @Input() foo!: string; constructor(p ...

Unexpected error arises in Typescript despite code functioning properly

As part of a practice project where I'm focusing on using webpack, ES6, npm and Typescript implementation, I have successfully set up loaders for 'awesome-typescript-loader' and 'babel-loader', which are bundling the code properly. ...

The argument passed to the AsyncPipe is not valid: '[object Object]'

Provided as shown below: public currentDBUserBS$: any; constructor(private afDb: AngularFireDatabase){} fetchUser(uid){ this.afDb.object(`users/${uid}`).valueChanges().subscribe((dUser) => { if (dUser) { this.currentDBUserBS$ = dUser; ...

Angular 2 Form Arrays

I need to create a new FormArray, but currently there is only one member in the array. When I try to create a new FormBuilder, it looks like this: public myAccountForm: FormGroup; ngOnInit() { this.myAccountForm = this._fb.group({ FullName: [ ...

The NG8002 error has occurred, as it is not possible to connect to 'matDatepicker' because it is not a recognized attribute of 'input'

I've come across an issue while working on my Angular 15 application with Angular Material. I'm trying to incorporate a date picker, but after adding the code snippet below, I encountered an error. <mat-form-field appearance="outline" ...

The compiler-cli encounters an error when it comes across dynamic declarations

I have encountered a significant project that was designed with the anticipation of transitioning to Angular 2.0 and enabling AoT compilation. After obtaining all the necessary API from Angular, I found that the project worked smoothly in JiT mode with Ang ...