Comments (8)
Have you tried demo-project or demo-ng8?
from mat-vs-table.
Yes, I saw demo-ng8 source code.
from mat-vs-table.
So, I realized what a problem. If you will recreate dataSource during the app lifecycle (for example after a state of data items will change) you will have this error.
Example of code:
ngOnInit(){
this.someObservable.subscribe(users => {
this.dataSource = new MatTableDataSource<User>(users);
});
}
In that case on second value from Observable you will get error.
from mat-vs-table.
So, I realized what a problem. If you will recreate dataSource during the app lifecycle (for example after a state of data items will change) you will have this error.
Example of code:ngOnInit(){ this.someObservable.subscribe(users => { this.dataSource = new MatTableDataSource<User>(users); }); }In that case on second value from Observable you will get error.
Thanks for pointing out the problem, but what if I have to recreate the datasource because of sorting? Am I unable to use this?
EDIT: The reason why mine was causing this, was because I was initilizing dataSource above(in the class) such as;
dataSource = new MatTableDataSource([]);
Then in the actual code function I recreated dataSource (since I am PULLING in the data and it is UNKNOWN during startup) Nearly every example ive seen is with known data. Anyways in the function I had
this.dataSource = new MatTableDataSource(tableArr);
from mat-vs-table.
I guess you can do the following instead of creating new MatTableDataSource each time
this.dataSource.data = users
You assign new data after you do searching.
from mat-vs-table.
I guess you can do the following instead of creating new MatTableDataSource each time
this.dataSource.data = users
You assign new data after you do searching.
I'm not sure if you're replying to my post, but I try not to change the data of the data source such as datasource.data . I use filtering and when changing the data, it won't filter correctly if I change the data. I would have to reload the datasource hurting performance
Edit: either way my problem is solved. It's working Amazingly. I'm having issues with sorting / resizing now. When resizing, it will also sort the column you release your mouse at while resizing.
from mat-vs-table.
Good to know the problem gets resolved. If you can provide demo in stackblitz, I can maybe help you.
from mat-vs-table.
Good to know the problem gets resolved. If you can provide demo in stackblitz, I can maybe help you.
It's 2:30am right now and I'm in bed but maybe tomorrow I'll see if I can set it up. I never used stack blitz but I'll check it out. Basically what is happening is that when you resize you click and hold your mouse, and if you let go in another cell, due to having matsort it also sorts at the same time. I tried adding a check to see if resizing but it isn't working correctly (to disable and enable sorting). Not only that, when resizing with a lot of elements it's very laggy. I was hoping adding this would help. It did help with scrolling A Lot but not resizing. Thanks for the help though! We're getting a bit off subject so please add me and DM me if you can. I appreciate the help again!
from mat-vs-table.
Related Issues (10)
- it is not working correctly with sticky: true HOT 6
- Flickering when scrolling HOT 1
- Doesn't display anything HOT 2
- Its not working for me. i am facing below issue HOT 7
- ERROR in : Can't bind to 'dataSource' since it isn't a known property of 'table'. HOT 6
- Table not displayed properly if display:none HOT 3
- ERROR!!!! this._coalescedStyleScheduler.schedule is not a function in "@angular/cdk": "^10.1.2"
- ERROR in angular 11
- [Angular 13] Error: export 'ɵɵstaticViewQuery'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mat-vs-table.