This tutorial demonstrates how to implement a modification that allows users to sort items of content modules and modules created by the Module builder by email and title in ascending and descending order.
The tutorial uses dynamic modules. You can use the same procedure for built-in content modules.
Create a new toolbar section in the following way:
Navigate to Administration » Settings » Advanced » DynamicModule » Controls » SelectYourModule » Views » Module_BackendList » Toolbar » Section » toolbar » Item.
Click Create new and select DynamicCommandWidgetElement.
Fill out the fields in the following way:
In Default page size, enter 15
In Header text, enter Sort Validation Codes
In Bind to, enter ComboBox
In Content type, enter Telerik.Sitefinity.DynamicTypes.Model.Test.Test
You can get the type of the module from Administration » Module Builder » <Your module> » Code reference for ... » Create .. and see the type in the section there. For example: Type testType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Test.Test");
In Name, enter ValidationCodesSortingWidget
In CssClass, enter sfQuickSort sfNoMasterViews
In WrapperTagName, enter Li
In Type, enter Telerik.Sitefinity.Web.UI.Backend.Elements.Widgets.SortWidget
Save your changes
Under the command widget you have created, click Data source
Click Create new.
To sort the items by email and title, create the following four sources - two for ascending and two for descending order:
In Title, enter EmailASC and in Value, enter Email ASC
In Title, enter EmailDESC and in Value, enter Email ASC
In Title, enter TitleASC and in Value, enter Title ASC
In Title, enter TitleDESC and in Value, enter Title DESC
RESULT: You are able to sort dynamic items by email and title. Furthermore, you can add more data sources and sort the items by other fields like author and etc.
To implement the sorting functionality for content items you can follow the steps above. All you need to change is the place where you will create the new item of the toolbar section the content type of the item. The item should be a new DynamicCommandWidgetElement for this specific content module. If you are trying to implement sorting functionality for Forms content type properties can be found in Administration -> Settings -> Advanced -> Forms -> Controls -> FormsBackend -> Views -> FormsBackendList . The only difference is in the content type of the DynamicCommandWidgetElement you are creating. For forms module you should use: Telerik.Sitefinity.Forms.Model.Form
Note that once you add or remove columns to the table (grid) where items are listed or reorder/regroup fields in the form for creating/editing content items, you need to create the item of the toolbox section again.
Back To Top