l-lin / angular-datatables

DataTables with Angular
https://l-lin.github.io/angular-datatables/
MIT License
1.58k stars 486 forks source link

How to remove sorting on the table at all? #1475

Closed nickelaos closed 4 years ago

nickelaos commented 4 years ago

I'm submitting a...


[ ] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[x ] Question

Current behavior

I want to disable the sorting on the table but didn't find a proper solution. I tried to disable sorting by columns with DTColumnDefBuilder but that is verbose, and the first column is sorted anyway. How do I remove sorting at all and display the data as it is being sent from the server?

Expected behavior

The sorting is not enabled on the table (by default it is sorted by the 1st column, even if all the columns are not sortable).

Minimal reproduction of the problem with instructions

vm.tblOpt = DTOptionsBuilder .newOptions() .withOption("scrollX", true) .withOption("scrollY", true) .withLanguageSource(lang_url);

const columnsCount = vm.tableData.xAxis.data.length + 1; vm.dtColumnDefs = [ ...Array.from(Array(columnsCount)).map((item, idx) => DTColumnDefBuilder.newColumnDef(idx).notSortable()) ];

Environment


- angular version: 1.7.9
- jquery version: 1.12.4
- datatables version: 1.10.18
- angular-datatables version: 0.5.7
nickelaos commented 4 years ago

Got it. I had to set sort: false on dtOptions object.