List and library control sort the table based on column

Hello,

Just wondering if its possible to sort a list and library control based on a field.

For example I would like to sort a list and library control based on a field position which has intiger values like 1 , 2 ,3 etc

Best Regards

Hello @Rinu,

Do you mean sorting or filtering?

You can sort items by clicking on the column header.
image

And filter items dynamically by one or multiple fields using the code. Please find example in our documentation here:
https://plumsail.com/docs/forms-sp/how-to/caml-filter.html

Thanks Mnikitina,
I meant sorting and and like to do it dinamically when page load based on a field.

@Rinu,

You can sort records in descending and ascending order using the code:

//ascending
fd.control('SPDataTable1').widget.dataSource.sort( { field: "ID", dir: "asc" });

//descending
fd.control('SPDataTable1').widget.dataSource.sort( { field: "ID", dir: "desc" });