while adding a new row element to the mat-table, notify the user what row has been added new to the list of rows
being able to notify the user where the new row has been added
no indication of when the data changed
Providing a StackBlitz reproduction is the best way to share your issue.
StackBlitz starter: https://goo.gl/wwnhMV
allow the user to identify where the new row has been added
Angular 5.2, Chrome
no
You can achieve that by creating a custom animation and apply it to the <mat-row>
First you can create a file to contain all your animations. For example: template.animations.ts
import { trigger, sequence, state, animate, transition, style } from '@angular/animations';
export const rowsAnimation =
trigger('rowsAnimation', [
transition('void => *', [
style({ height: '*', opacity: '0', transform: 'translateX(-550px)', 'box-shadow': 'none' }),
sequence([
animate(".35s ease", style({ height: '*', opacity: '.2', transform: 'translateX(0)', 'box-shadow': 'none' })),
animate(".35s ease", style({ height: '*', opacity: 1, transform: 'translateX(0)' }))
])
])
]);
The animation is rowsAnimation and it has the transition void => *that applies when the element enters the view, regardless of what state it will have later.
More info about animations:
https://angular.io/guide/animations
In your html template, add the animation to the <mat-row>
<mat-row [@rowsAnimation]="" *matRowDef="let row; columns: displayedColumns;"></mat-row>
In your ts file, import the animation from the previous file and provide it to the animation array in the component declaration:
import { rowsAnimation } from './animations/template.animations';
@Component({
selector: 'material-app',
templateUrl: 'app.component.html',
animations: [rowsAnimation],
})
Now each time you add new data to the datasource the animation appears
I have created a StackBlitz with the full example:
https://stackblitz.com/edit/angular-material-addrow-example
Closing, as noted in the response above, you should be able to control the animation of rows using Angular's Animations API.
Thanks Joe and Patrick
On Mon, Mar 26, 2018 at 4:45 PM, Joey Perrott notifications@github.com
wrote:
Closed #10417 https://github.com/angular/material2/issues/10417.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/angular/material2/issues/10417#event-1541203153, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AEW4ET51cNQCWUjbKDTMdPlNrPuvXBgUks5tiQ02gaJpZM4SqJc0
.
Hi @patrickqsos can we add a manual data instead of pushing some random data into it
@chethan1095 Yes. the stackblitz example has a function createNewUser that returns an instance of UserData with random data that is added to the datasource of the mat-table. Inside that function you can manually call your backend or retrieve info from some service to get data you need
I have been searching for a while on how to do this. In material they demonstrate everything in the overview but there is no link for developers to find out how to do it. Luckily your code survived here and probably will try that. I never actually realised the animations need to be done in Angular and not with Material.
Not sure but your angualr guides link goes to a not found git hub page instead of
https://angular.io/guide/animations
And the stackblitz has been obliterated.
Am a complete noob at this but have seen a few Stack Overflow questions with no answers.
@patrickqsos
I was actually looking the same thing. but unfortunately the link you shared is not working.
https://stackblitz.com/edit/angular-material2-issue-mxouqy
Could you please help us.
Hi, here is the updated link:
https://stackblitz.com/edit/angular-material-addrow-example
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
You can achieve that by creating a custom animation and apply it to the
<mat-row>First you can create a file to contain all your animations. For example: template.animations.ts
The animation is rowsAnimation and it has the transition void => *that applies when the element enters the view, regardless of what state it will have later.
More info about animations:
https://angular.io/guide/animations
In your html template, add the animation to the
<mat-row><mat-row [@rowsAnimation]="" *matRowDef="let row; columns: displayedColumns;"></mat-row>In your ts file, import the animation from the previous file and provide it to the animation array in the component declaration:
Now each time you add new data to the datasource the animation appears
I have created a StackBlitz with the full example:
https://stackblitz.com/edit/angular-material-addrow-example