Table functions > Default sorting

Crud Elite

Getting Started

Action Column

Hide action column

Add buttons to action column

Table functions

Default sorting

“Show 10 records” drop-down

The “Search…” placeholder

Exported file

Columns ordering

Custom content in a column

Confirm delete popup

Common issues

Edit auratheme.table.js

Other

Clone for another table

How it works

Read data for the table

How to change the default sorting?


There are times when you want the table to be sorted by the "Name" column in ascending order by default. Other times, you may prefer to sort it by the "CreationDate" column instead. Here's how you can set the default sorting order of the table based on your needs.

The steps


Edit the DefaultSortOrder in ClientTableConfig. The screenshot below means that, by default, the table listing is sorted by the Name column in ascending order (appending -asc behind it). If you want to sort by descending order, use -desc instead. Below are some examples.

$"{nameof(ClientViewModel.**Name**)}**-asc**" Sort by Name column in ascending order
$"{nameof(ClientViewModel.**Name**)}**-desc**" Sort by Name column in descending order
$"{nameof(ClientViewModel.**CreationDate**)}**-asc**" Sort by CreationDate column in ascending order
$"{nameof(ClientViewModel.**CreationDate**)}**-desc**" Sort by CreationDate column in descending order

image.png