Nilesh007
Nilesh007

Reputation: 119

How can I reset primeng datatable sort state?

I'd like to reset the sort state of primeng datable. i am able to reset full datatable but still sort state is not reset

Upvotes: 11

Views: 14514

Answers (1)

Yonatan Ayalon
Yonatan Ayalon

Reputation: 2037

This worked for me:

HTML

<p-table #table ...>

TS

import {Table} from 'primeng/table';

@ViewChild('table') table: Table;

resetSort() {
 this.table.sortOrder = 0;
 this.table.sortField = '';
 this.table.reset();
}

Upvotes: 10

Related Questions