Implementing search for Users Administration screen in Sitefinity backend

Implementing search for Users Administration screen in Sitefinity backend

Posted on January 12, 2012 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

NOTE:

Please note that the template has been revised to address the changes in Sitefinity 5.0 SP1 - build 5.0.2800

If you're experiencing any problems running the sample in the above mentioned version, please download the revised template - UsersListCustom and replace the old one in your ControlTemplates folder.

 

Many of you have requested an easier way to search for users in Sitefinity backend Users Administration. Such functionality can be really useful to ones managing projects with multiple users, where searching for a particular user may become a tedious task.

To address your feedback, we have scheduled the implementation of this feature for our upcoming Sitefinity 5.1 release. In the meantime, however, I'll list below a quick workaround that will allow you to enjoy the same functionality.

 Let me elaborate a little bit on what we'll be doing. By default the control used to display the users in /Sitefinity/Administration/Users is being bound client-side, so we'll just modify the template used there slightly, to pass a desired value (username) to the service responsible for getting the users. With a minimum amount of intervention we'll end up having a textbox and a search button, which when clicked filters the list, returning those users who match (have in mind we're using sub-string match, so you can look for users by parts of their UserName as well).

What we're adding to the default template is pretty simple - a textbox for entering the UserName and a button to submit the data to the service. They are both added to the command actions ribbon on top of the users grid control:

<li>
      <asp:TextBox runat="server" ID="SearchUserName"/>
      <asp:Button Text="Search" ID="SearchUserButton"
        runat="server" OnClientClick="SearchUserButton_Click(); return false;"  />
</li>

We'll be handling the Click event with a client-side function which reads the value entered in the textbox and sets the filterExpression for the service:

function SearchUserButton_Click() {
       var searchUserName = $get('<%= SearchUserName.ClientID %>');
       var urlParams = [];
       if (searchUserName != null) {
           if (searchUserName.value != null) {
               _currentFilter = "UserName.Contains(\"" + searchUserName.value + "\")";
               Bind(urlParams);
           }
       }
   }
You can find attached to this post a sample modified template ready to be extracted in your project, and you'll just need to map it in Sitefinity backend by going to Administration->Settings->Advanced->Controls->ViewMap and creating a new entry there. please fill in the boxes accordingly:

HostType: Telerik.Sitefinity.Security.Web.UI.Principals.UsersList

LayoutTemplatePath: enter here the application relative path to the template you've extracted in your project (for your convenience I'm also attaching a screenshot demonstrating the mapping settings in my local project.)

Save the changes and restart your application to make sure you're not loading the cached version of the template.

For more information on mapping external templates globally for Sitefinity, I believe you might find this great post by Josh Morales very useful.

 

You should now have the searchbox in your /Sitefinity/Administration/Users screen, enjoy the new feature you've added to your project and please do not hesitate to let us know of any other improvements or constructive feedback you might have on the product functionality. We'll be glad to address them.

 

Attachments:

UsersListCustom

MapUsersListTemplate

UserSearch_implemented

progress-logo

The Progress Team

View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments

Comments are disabled in preview mode.
Topics

Sitefinity Training and Certification Now Available.

Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.

Learn More
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

Loading animation