SF 5.1 Lists items sorting [ fix inside ]
Hi,
If you have the requirement to sort your list items when you display the items in a widget, know that sorting the list items using the toolbar actions ( manually, alphabatically AZ or ZA....) in the backend is meant to persist the sorting and apply it in the Lists Widget.
However, there is a Javascript
bug that prevents it from working properly in Sitefinity 5.1 SP1 (haven't tried SP2).
Here is a fix i have found to make this work :
1) Add the following class to your Sitefinity project :
ScriptFix is the path to a javascript file that will redefine a javascript function set in Sitefinity embedded file.using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
namespace
SitefinityWebApp.Backend
using
Telerik.Sitefinity.Web.UI.ContentUI.Views.Backend.Master;
using
Telerik.Sitefinity.Web.UI.ContentUI.Views.Backend.Master.Contracts;
/// <summary>
/// Overrides the master grid view for ItemsBackendList view.
/// </summary>
public
class
ItemsBackendListMasterGridView : MasterGridView
/// <summary>
/// Initializes the controls.
/// </summary>
/// <param name="container">The container.</param>
/// <param name="definition">The view definition</param>
protected
override
void
InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container, Telerik.Sitefinity.Web.UI.ContentUI.Contracts.IContentViewDefinition definition)
base
.InitializeControls(container, definition);
var masterViewDefinition = definition
as
IMasterViewDefinition;
if
(masterViewDefinition !=
null
)
const
string
ScriptFix =
"~/Scripts/Web.Scripts.ListItemsMasterGridViewExtensionsFix.js"
;
if
(masterViewDefinition.ExternalClientScripts !=
null
&& !masterViewDefinition.ExternalClientScripts.ContainsKey(ScriptFix))
masterViewDefinition.ExternalClientScripts.Add(ScriptFix,
"OnMasterViewLoaded"
);
Telerik.Sitefinity.Modules.Lists.Web.UI.ListItemsMasterGridViewExtensions.prototype._getListsModuleServiceUrl =
function
(itemsListBase)
var
serviceUrl = itemsListBase.get_serviceBaseUrl();
serviceUrl = serviceUrl.replace(
'ListItemService.svc'
,
'ListsModuleService.svc'
);
if
(serviceUrl.lastIndexOf(
'?'
) != -1)
serviceUrl = serviceUrl.substr(0, serviceUrl.lastIndexOf(
'?'
));
return
serviceUrl;
<
view
xmlns:config
=
"urn:telerik:sitefinity:configuration"
xmlns:type
=
"urn:telerik:sitefinity:configuration:type"
config:version
=
"5.0.2800.0"
viewType
=
"SitefinityWebApp.Backend.ItemsBackendListMasterGridView"
viewName
=
"ItemsBackendList"
>
<
view
xmlns:config
=
"urn:telerik:sitefinity:configuration"
xmlns:type
=
"urn:telerik:sitefinity:configuration:type"
config:version
=
"5.0.2800.0"
viewName
=
"ItemsBackendList"
>
<!-- skipped dialog config -->
<
scripts
>
<
script
loadMethodName
=
"OnMasterViewLoaded"
scriptLocation
=
"~/Scripts/Web.Scripts.ListItemsMasterGridViewExtensionsFix.js"
/>
</
scripts
>
</
view
>