Sorting may be one of the simplest concepts in any application, however, if you don’t understand the prioritising of sorting within a K2 SmartForms ListView, you can find yourself running in circles to apply the correct sorting.
First we will discuss the different ways to apply sorting on a K2 SmartForms ListView after which we will discuss the K2 prioritising of these different sorting methods.
K2 Automated Testing Software
BenchQA allows full test automation of K2, including fully automated K2 SmartForms and K2 Workflow testing. It promotes test driven development for K2 and ensures continued quality assurance for K2 solutions. Easily apply changes to test cases to accommodate changes to K2 apps and ensure all apps are regression tested to avoid defects and assure continuous quality.
The first option is server-side sorting by either sorting within your SQL stored procedure or your service method.
The second option is to apply sorting from the ListView settings. You can find these options from the ListView layout by clicking on the blue cogwheel.
In the “Sort” section select configure.
You can choose items for the ListView to sort by from the SmartObject you selected when you created the View. If you add more than one item the sorting will be applied for both ordered from the top. You can also choose the sort order – ascending or descending.
The third option is to apply sorting whenever you call the method that loads the list data. This option means that you can have a different sorting for every different list load.
On the list load rule click on configure to set up the sorting.
You can choose items for the ListView to sort by from the SmartObject you selected when you created the View. If you add more than one item the sorting will be applied for both ordered from the top. You can also choose the sort order – ascending or descending.
The order in which the sorting will be applied within the K2 SmartForms ListView is:
1. List load method sorting (Option 3)
2. ListView options sorting (Option 2)
3. Server-side sorting (Option 1)
It is important to note that your server-side sorting will be overridden should you have any K2 sorting (option 2 or 3 ) set up. You should also always ensure that your SmartObjects are set to the correct datatype to avoid incorrect sorting since dates, times and numbers will not sort correctly if the datatypes are set to text for example.