swimlane / ngx-datatable

✨ A feature-rich yet lightweight data-table crafted for Angular
http://swimlane.github.io/ngx-datatable/
MIT License
4.63k stars 1.68k forks source link

Type '"multi"' is not assignable to type 'SortType'. #2071

Open ninoguba opened 2 years ago

ninoguba commented 2 years ago

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

When building app for production, it fails with the following message:

error TS2322: Type '"multi"' is not assignable to type 'SortType'.

The error happens too if using [sortType]="'single'".

Expected behavior

No build errors related to ngx-datatable.

Reproduction of the problem

Add sortType attribute to your ngx-datatable component.

What is the motivation / use case for changing the behavior?

N/A

Please tell us about your environment:

julianlumets commented 2 years ago

I have a solution, you have to change the html to: [sortType]="SortType.multi"

And you have to declare a variabele in the typescript file (above the constructor) like ( and dont forget to import SelectionType):

SortType = SortType;

Import: import { ColumnMode, SortType } from 'projects/swimlane/ngx-datatable/src/public-api';

I found this answer in the official docs (the same for selection and sorting): https://github.com/swimlane/ngx-datatable/blob/master/src/app/selection/selection-single.component.ts http://swimlane.github.io/ngx-datatable/#single-selection

ninoguba commented 2 years ago

I was able to workaround the issue by setting this in my html:

[sortType]="sort"

And this in my component:

sort: any = 'multi';