最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do you clear out the sorting icons in ngx-datatable? - Stack Overflow

programmeradmin0浏览0评论

I'm using ngx-datatable with Angular 5.0 and am implementing sorting with externalSorting set to true as I am doing server side pagination and sorting in the backend. I have a button that on click, resets the data in the table to the data that is displayed on load, so that when a bunch of sorting is done, the user can reset to the original view. It works as intended, however I don't know how to clear out the sorting icons in the column header. Is there a way to do this?

I'm using ngx-datatable with Angular 5.0 and am implementing sorting with externalSorting set to true as I am doing server side pagination and sorting in the backend. I have a button that on click, resets the data in the table to the data that is displayed on load, so that when a bunch of sorting is done, the user can reset to the original view. It works as intended, however I don't know how to clear out the sorting icons in the column header. Is there a way to do this?

Share Improve this question asked Apr 30, 2018 at 15:20 MeesterMarcusMeesterMarcus 7101 gold badge10 silver badges27 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

The solution ended up being creating a reference to the ngx-datatable element, and setting the sorts array to a blank array.

Example HTML:

<ngx-datatable #table
   class="material"
   [columns]="cols"
   [rows]="rows"
>

And TypeScript:

@ViewChild(DatatableComponent) table: DatatableComponent;

reset() {
    this.table.sorts = [];
}
发布评论

评论列表(0)

  1. 暂无评论