const defaultSort = {
field: "column1",
sortOrder: 1,
};
<DataTable
id="table_searchResults"
:value="searchResults"
:paginator="true"
:rows="defaultRowsPerPage"
paginatorTemplate="Rows per page: RowsPerPageDropdown FirstPageLink PrevPageLink CurrentPageReport NextPageLink LastPageLink"
:rowsPerPageOptions="rowsPerPage"
currentPageReportTemplate="{currentPage} of {totalPages}"
:sortField="defaultSort.field"
:sortOrder="defaultSort.sortOrder"
lazy
:totalRecords="totalElements"
></DataTable>
Lazy datatable with default sort. After doing sort on another column, performing search is not resetting the table to default sort column.
Any thoughts?
Define a ref value for your table and use it to set the sort field and order.
tableRefValue.value.d_sortField = defaultSort.field;
tableRefValue.value.d_sortOrder = defaultSort.sortOrder;