Sort Table by colums from Database

Hi everyone,
I need help. Does anyone know how to set Table to be able to sort table by every colum of Table?

Thanks

Hi pavlina,
If you want the table have an option for sort, it sims doesn’t have it. : )
You can use text input or other trigger you want to do so.

Code with sorting,
import wixData from ‘wix-data’;

//…
export function textInput_keyPress ( ) {
var searchInput = $w( “#textInput” ) .value;
if ( searchInput !== null ) {
$w ( "# dataset " ) . setSort ( wixData.sort( ) . descending ( " property " )
. contain ( " property ", searchInput )
.or ( wixData.query( " DatabaseName " ).contain ( " property ", searchInput ) ) );
} else {
$w ( "# dataset " ) . setSort ( wixData.sort( ) );
}
}

export function searchCancelButton_click( ) {
$w( “#textInput” ) .value = null ;
}

Remark,
If you want to clear sort when the cancelButton was clicked, you can also add the code below into cancel trigger.
$w( "# dataset " ) . setSort ( wixData.sort( ) );

For inspire,
Using dataset.setSort can also have the loadMore( ) action. Let the number of data need to display on page load can become fewer. For example,

//…
export function anchor_viewportEnter ( ) {
$w ( "# dataset " ) . loadMore( ) ;
}

Hope useful. Good luck,
Heson