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

sortable: false is being ignored #728

Open lobo-tuerto opened 7 years ago

lobo-tuerto commented 7 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

sortable: false in column definitions is being ignored.

Expected behavior

Columns defined with sortable: false should not be sortable.

Reproduction of the problem

With remote sorting enabled, if you define your columns and assign them sortable: false they are still sortable.

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

So you can make your columns unsortable.

Please tell us about your environment:

MuhammedHasan commented 7 years ago

comparator as well

ychaikin commented 7 years ago

@lobo-tuerto, curious, are you using ngx-datatable-column in your template? And if so, are you explicitly passing in [sortable]="columnObj.sortable" or something like that?

I got burned on that because I thought that if you pass columns into the ngx-datatable itself with a particular column having sortable be false, it would pick it up. However, apparently, if you specify a custom ngx-datatable-column, you have to pass that input into that explicitly. Once you do, it does what you would expect.

Perhaps, @amcdnl can correct me on that if I am wrong.

lobo-tuerto commented 7 years ago

@ychaikin Yeah, exactly that was my asumption too!!

Thanks a lot for taking your time to explain the solution, I think this should be in the documentation somewhere, maybe in the column definition section.

lobo-tuerto commented 7 years ago

@amcdnl Would it be bad design or difficult (or possible at all) to pick the sortable config from the columns definition if not passed explicitly to ngx-datatable-column?

eduardotoural commented 7 years ago

If you are using ngx-datatable, and you are are using ngx-datatable-column, for each column, to disable the "sort" you have to add "[sortable]="false"" for each ngx-datatable-column, example:

<ngx-datatable ...> <ngx-datatable-column name="First Name" [sortable]="false" prop="firstName" /> </ngx-datatable>

Doing this, you are disabling the "sort" capability in the column header for each column.

djpysu commented 6 years ago

Can someone please help with this one?

<ngx-datatable-column [minWidth]="100" [maxWidth]="100" [sortable]='false'> won't work.

FrancescoBorzi commented 6 years ago

the following works for me:

<ngx-datatable-column [sortable]="false" prop="id" name="ID"></ngx-datatable-column>

using:

[externalPaging]="true"
[externalSorting]="true"

using version 11.2.0 with Angular 5

gusgad commented 5 years ago

[sortable]='false' does not work, Angular 6.1.0