More in this section

Forums / Developing with Sitefinity / Custom List Provider

Custom List Provider

5 posts, 0 answered
  1. LBrinley
    LBrinley avatar
    59 posts
    Registered:
    29 Dec 2005
    02 Mar 2010
    Link to this post
    I have had no problem with Membership/Role providers and GenericContent-based custom providers, but I cannot for the life of me get a custom list provider created in web.config to show up in the dropdown for the Lists Module.  I've checked the User's Manual (GC provider example only) and searched these forums repeatedly to no avail, so I finally broke down and decided to post this question.  What, exaclty, do I need to do in web.config to get a custom List provider to become available within the Sitefinity Lists module?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    03 Mar 2010
    Link to this post
    Hi iVillageIdiot,

    List is not GenericContent based module and this is why adding the provider name in the web.config does not reflect in showing a DropDownList. This problem will be fixed for the next SP  - Middle of March right after Q1 of Telerik RadControls for ASP.NET AJAX release.

    What you can do

    1. Create  a custom module class that inherits from ListModule and override CreateControlPanel method.

    public override Control CreateControlPanel(TemplateControl parent)
    {
         return new CustomListsControlPanel();
    }


    2. Create CustomLitsControlPanel and add the following method in it.

    protected override string[] GetProviderNames()
     {
         List<string> providers = new List<string>();
         foreach (System.Configuration.ProviderSettings element in Telerik.Lists.Configuration.ConfigHelper.Handler.Providers)
         {
             GlobalPermission perm = new GlobalPermission(
                 (GlobalPermissions)ListManager.SecurityRoots[element.Name], CrudRights.View);
             if (perm.CheckDemand())
                 providers.Add(element.Name);
         }
         return providers.ToArray();
     }


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. LBrinley
    LBrinley avatar
    59 posts
    Registered:
    29 Dec 2005
    03 Mar 2010
    Link to this post

    Thank you for the suggested solution, but it results in the following Stack Trace when I enter the Lists Module in Admin:

    [NullReferenceException: Object reference not set to an instance of an object.]
       Telerik.Cms.Web.UI.Backend.BackendBreadcrumb.CreateChildControls() +39
       System.Web.UI.Control.EnsureChildControls() +87
       System.Web.UI.Control.PreRenderRecursiveInternal() +44
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

    This is in Sitefinity 3.7SP2. The code of the CustomListsControlPanel follows:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using Telerik.Lists.Security;
      
    /// <summary>
    /// Summary description for CustomListsControlPanel
    /// </summary>
    public class CustomListsControlPanel : Telerik.Cms.Web.UI.Backend.ProviderControlPanel<CustomListsControlPanel>
    {
        public CustomListsControlPanel()
        {
        }
      
        protected override string[] GetProviderNames()
        {
            List<string> providers = new List<string>();
            foreach (System.Configuration.ProviderSettings element in Telerik.Lists.Configuration.ConfigHelper.Handler.Providers)
            {
                GlobalPermission perm = new GlobalPermission((GlobalPermissions)Telerik.Lists.ListManager.SecurityRoots[element.Name], Telerik.Security.Permissions.CrudRights.View);
                if (perm.CheckDemand())
                {
                    providers.Add(element.Name);
                }
            }
            return providers.ToArray();
        }
    }
     
    I don't understand why the Breadcrumbs backend control seems to be having fits.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    03 Mar 2010
    Link to this post
    Hi iVillageIdiot,

    You do not have to create the ControlPanel from scratch. Here is a working sample

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Lists;
    using System.Web.UI;
     
    /// <summary>
    /// Summary description for ListsModuleCustom
    /// </summary>
    public class ListsModuleCustom : ListModule
    {
        public ListsModuleCustom()
        {
     
        }
     
        public override string Name
        {
            get
            {
                return "ListsModuleCustom";
            }
        }
     
        public override string Title
        {
            get
            {
                return "ListsModuleCustom";
            }
        }
     
        public override Control CreateControlPanel(TemplateControl parent)
        {
            return new CustomListsControlPanel();
        }
    }

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Lists.WebControls.Admin;
    using Telerik.Lists.Security;
    using Telerik.Lists;
    using Telerik.Security.Permissions;
     
    /// <summary>
    /// Summary description for CustomListsControlPanel
    /// </summary>
    public class CustomListsControlPanel : ListsControlPanel
    {
        public CustomListsControlPanel()
        {
     
        }
     
        protected override string[] GetProviderNames()
        {
            List<string> providers = new List<string>();
            foreach (System.Configuration.ProviderSettings element in Telerik.Lists.Configuration.ConfigHelper.Handler.Providers)
            {
                GlobalPermission perm = new GlobalPermission(
                    (GlobalPermissions)ListManager.SecurityRoots[element.Name], CrudRights.View);
                if (perm.CheckDemand())
                    providers.Add(element.Name);
            }
            return providers.ToArray();
        }
     
    }


    Regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. LBrinley
    LBrinley avatar
    59 posts
    Registered:
    29 Dec 2005
    03 Mar 2010
    Link to this post
    Ivan,

    Thanks for the spoon-feeding.  It all works now.

    What's annoying is that I did, in fact, try a version of my ListsControlPanel where I inherited from Telerik.Lists.WebControls.Admin.ControlPanel, but it didn't work.  Guess I was too lazy to notice the ListsControlPanel class in the same namespace.

    Thanks again.
Register for webinar
5 posts, 0 answered