In this section, we will see how to sort Table data in VBCS.
Let us consider the EmpBOData Business Object.

Let us create sample VBCS page with table based on above business object.

Run the application.

We want to sort this table data based on some specified column name.
When we use a business object, it creates an SDP variable.
For our example, empBODataListSDP is created as shown below.
Sorting to table data can be by using one of two options:
(A) orderBy
(B) sortCriteria

-
Sorting Table Data using orderBy
Let us consider, we need to sort the table data based on the FirstName field.
Click on orderBy under SDP as highlighted above and provide FirstName in orderBy

Click on Save.
Run the application.

We can see, data is sorted based on firstName in ascending order.
We can sort data based on firstName in descending order using desc as shown below:

Click on Save.
Run the application.

Data is sorted now based on firstName in descending order.
We can also add multiple columns for sorting data as shown below:

Click on Save.
Run the application.

-
Sorting Table Data using sortCriteria.
To sort table data using sorting Criteria, click on sortCriteria:

Expand sortCriteria and item[i] which will consists of below two fields:
-
attribute: enter the name of the field for which you want data to be sorted. Example -firstName
-
direction: specify the sort direction, either asc for ascending or dsc for descending.


Click on save.
Run the application.

Data is sorted based on firstName in descending order.
We can also add multiple sort criteria as shown below:
