Sorting users in the Sitefinity Backend

Since version 8.x and higher, there is a bug that when users are sorted by name in the backend both in ascending or descending order, they are not sorted correctly.

Daniel Plomp

July 23rd, 2020

Problem

Sitefinity has a friendly user interface for all kinds of activities. One of them is maintaining the backend users that have access to the CMS. Since version 8.x and higher, there is a bug that when users are sorted by name in the backend both in ascending or descending order, they are not sorted correctly.

Progress confirms this bug, and you can read more information about it here: 
Bug 230852 see http://feedback.telerik.com/Project/153/Feedback/Details/230852

Solution

We can work around this issue by writing some custom code in our Sitefinity Web application.

Step 1. Create a custom class in your project
First, we are going to add a custom class in our project that implements the IUser interface. This way, we can adjust some of the methods that Sitefinity needs for showing and sorting users in the backend.

I've named my custom class SortableUsers.

Step 2. Write the implementation
When you have your class ready and implement the IUser interface, it is time to implement each method needed by the IUser interface.

Almost every method is making use of the BaseService property defined on top of the class. The GetUser() and the SearchUsers() methods need a custom implementation to get the sorting function to work correctly.

Step 3. Register our SortableUsers service
To let Sitefinity use our custom service instead of its own service, we need to register our custom service and map it to the default one. We will do this when the Sitefinity bootstrapper is initialized.

Step 4. Build your project and sort that users
When all the code is in place, you may want to build your project and check out the working solution!

All rights reserved © ZimplerApps 2020