Custom comparator + columns width
See original GitHub issueI’m submitting a … (check one with “x”)
[x] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter
Current behavior It’s possible to add a custom comparator for a column in the class like that :
columns = [
{ name: 'Company', comparator: this.companyComparator.bind(this) },
{ name: 'Name', sortable: false },
{ name: 'Gender', sortable: false }
];
It’s also possible to fixe the columns width in the template like that :
<ngx-datatable
[columnMode]="'force'"
...
[rows]="rows">
<ngx-datatable-column name="Name" [width]="100"></ngx-datatable-column>
...
</ngx-datatable>
But it seems impossible to set the column width in the class or to set the comparator in the template.
Expected behavior To be able to set both the columns width and the comparator in the class like that :
columns = [
{ name: 'Company', width: '100', comparator: this.companyComparator.bind(this) },
{ name: 'Name', width: '300', sortable: false },
{ name: 'Gender', width: '300', sortable: false }
];
And to be able to set both the columns width and the comparator in the template like that :
<ngx-datatable
[columnMode]="'force'"
...
[rows]="rows">
<ngx-datatable-column name="Name" [width]="100" comparator="customComparator()"></ngx-datatable-column>
...
</ngx-datatable>
Reproduction of the problem
What is the motivation / use case for changing the behavior? I need to set width because some columns are just a short number, others are long string. Furthermore, I also need to set a custom comparator because one of my columns contains date.
Please tell us about your environment: Win 10
-
Table version: 0.8.x 9.1.0
-
Angular version: 2.0.x 4.0.0
-
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] all
-
Language: [all | TypeScript X.X | ES6/7 | ES5] TypeScript 2.2.2
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:10 (1 by maintainers)
Top GitHub Comments
@Ryan-Haines , here is a simple comparator example: https://stackblitz.com/edit/angular-lsjnep
You can set custom comparator in this way: In your component ts file: customComparator = (a, b) => … And in your template file: [comparator]=“customComparator”