Open IngoManthey opened 7 years ago
The messages are bound to a field which by default is called messages. This object has emptyMessage
etc as fields. These are read by the ngx-datatable.
You can override this default messages
as such:
<ngx-datatable
[messages]="my_messages"
you can then populate the object in the component:
my_messages = {
'emptyMessage': '',
'totalMessage': ''
};
constructor(private translate: TranslateService) {
translate.get('LIST_TOTAL', {value: ''})
.subscribe((res: string) => this.my_messages.totalMessage = res);
translate.get('LIST_NO_RESULTS', {value: ''})
.subscribe((res: string) => this.my_messages.emptyMessage = res);
}
}
where LIST_TOTAL is a key in the messages
Even better, it can be done in the markup. See: https://github.com/swimlane/ngx-datatable/issues/589#issuecomment-300906484
@jeroenwijdemans Your example only applies to ngx-datatable, it doesn't work that way with Angular's built-in i18n (that I'm using). We'd need to have a DOM element to apply the i18n
directive on it.
Hello, I read: Static messages in the table you can override for localization. emptyMessage: 'No data to display', totalMessage: 'total'
I try: import { NgxDatatableModule } from '@swimlane/ngx-datatable';
ngOnInit() { NgxDatatableModule. but there are no emptyMessage or totalMessage properties for change the text.
Thanks for your help.
regards