+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Library BatchEdit Category not saving

Library BatchEdit Category not saving

11 posts, 0 answered
  1. Karl
    Karl avatar
    45 posts
    Registered:
    18 Jun 2009
    06 Jun 2011
    Link to this post
    Hi,
    I have enabled the feature for including the category batch edit to allow users to categorys. However I wanted to only display  categorys associetded to that library.

    I came across another post/article about implmenting your own, this is the code:
    namespace Telerik.Samples
    {
        public class BatchContentCategoriesField : ContentCategoriesField
        {
            public BatchContentCategoriesField()
            {
            }
              
            // set the template for CategoriesField.ascx 
            public override string LayoutTemplatePath
            {
                get
                {
                    if (string.IsNullOrEmpty(this.layoutTemplatePath))
                        this.LayoutTemplatePath = "~/Sitefinity/Admin/ControlTemplates/Generic_Content/CategoriesField.ascx";
                    return this.layoutTemplatePath;
                }
                set
                {
                    this.layoutTemplatePath = value;
                }
            }
      
            // override initialize controls 
            protected override void InitializeControls(System.Web.UI.Control controlContainer)
            {
                base.InitializeControls(controlContainer);
               // this.CategoriesList.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(CategoriesList_SelectedIndexChanged);
                this.CategoriesList.Items.Clear();
                  
              
                    string yourProviderName = "Libraries";
                    Telerik.Cms.Engine.ContentManager contentManager = new ContentManager(yourProviderName);
                    IList categories = contentManager.GetCategoriesTree(contentManager.GetCategory(Common.GetLib(Page.Request.QueryString["ParentId"])));
                 
      
                RadComboBoxItem liUncategorized = new RadComboBoxItem();
                liUncategorized.Text = "-- uncategorized --";
                liUncategorized.Value = string.Empty;
                this.CategoriesList.Items.Add(liUncategorized);
                AddCategory(Guid.Empty, categories);
            }
      
            /// <summary> 
            /// Adds the category. 
            /// </summary> 
            /// <param name="parentId">The parent id.</param> 
            /// <param name="categories">The categories.</param> 
            private void AddCategory(Guid parentId, IList categories)
            {
                foreach (ICategory category in categories)
                {
      
                    if (this.CategoriesList.FindItemByValue(category.ID.ToString()) == null && category.ParentCategoryID == parentId)
                    {
                        RadComboBoxItem categoryItem = new RadComboBoxItem(category.CategoryName, category.CategoryName);
                        int level = CalculateLevel(category, categories);
      
                        if (level > 0)
                            categoryItem.Style.Add("padding-left", string.Concat((10 * level), "px"));
                        if (category.CategoryName == selectedCategory)
                            categoryItem.Selected = true;
      
                        this.CategoriesList.Items.Add(categoryItem);
                        AddCategory(category.ID, categories);
                    }
      
                }
            }
      
      
      
            /// <summary> 
            /// Calculates the level. 
            /// </summary> 
            /// <param name="category">The category.</param> 
            /// <param name="categories">The categories.</param> 
            /// <returns></returns> 
            private static int CalculateLevel(ICategory category, IList categories)
            {
                int level = 0;
                while (category.ParentCategoryID != Guid.Empty)
                {
                    level++;
                    foreach (ICategory category1 in categories)
                    {
                        if (category.ParentCategoryID == category1.ID)
                        {
                            category = category1;
                            break;
                        }
                    }
                }
                return level;
            }
      
            private IContent content;
            private string selectedCategory;
            private string layoutTemplatePath;
        }
    }

    <%

     

    @ Register TagPrefix="cus" Namespace="Telerik.Samples" Assembly="App_Code" %>

     

    <

     

     

    cus:BatchContentCategoriesField ID="commonCategories" runat="server"></cus:BatchContentCategoriesField>

    The drop down gets populated but when I go to save it does not save?

    Thanks

     

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    06 Jun 2011
    Link to this post
    Hi Karl,

    Try setting the ID of your control to Category. In the base ContentItemEdit we handle only one control that implements IContentCategoriesField and this control should have ID="Category"

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Karl
    Karl avatar
    45 posts
    Registered:
    18 Jun 2009
    07 Jun 2011
    Link to this post
    Hi,
    Nope still does not work. Looking at the orginal templates that you have to download from your site this is the category dropdown: (Common Categories

     

     

    <fieldset class="set">

     

     

     

    <div class="setIn batchtags">

     

     

    <%

     

    --<asp:Label runat="server" AssociatedControlID="commonCategories" Text="<%$Resources:Category %>"></asp:Label>

     

     

    <sf:CategoriesField ID="commonCategories" runat="server" />--

     

     

    %>

     

     

     

     

    <sf:ContentTagEditor ID="commonTags" runat="server" />

     

     

     

    </div>

     

     

     

    </fieldset>

    This is what I have now:

     

     

     

    <fieldset class="set">

     

     

     

    <div class="setIn batchtags">

     

     

     

    <asp:Label ID="Label1" runat="server" AssociatedControlID="Categories" Text="<%$Resources:Category %>"></asp:Label>

     

    <%

     

    --<sf:CategoriesField ID="commonCategories" runat="server" TemplatePath="~/Sitefinity/Admin/ControlTemplates/Generic_Content/CategoriesField.ascx" />--%>

     

     

     

     

    <cus:BatchContentCategoriesField ID="Categories" runat="server"></cus:BatchContentCategoriesField>

     

     

     

    <sf:ContentTagEditor ID="commonTags" runat="server" />

     

     

     

    </div>

     

     

     

    </fieldset>

     


    Thanks
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    09 Jun 2011
    Link to this post
    Hello Karl,

    The changes to the first page should be saved. There might be an issue if you go the subpages -2. 3. 4. 5 etc and you try to associate items that are shown on these pages. This a bug related to the batchedit itself. If you try to save only the first page do you have issues?

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Karl
    Karl avatar
    45 posts
    Registered:
    18 Jun 2009
    09 Jun 2011
    Link to this post
    Hi,

    The below is a screen recording:
    http://screencast.com/t/TXNq2PYgF88q
    There are only 2 items to batch edit so no paging is involved.

    Thanks

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    13 Jun 2011
    Link to this post
    Hello Karl,

    Ok I saw what the problem is. You inherit from  ContentCategoriesField since you should inherit from CategoriesField. Currently your control returns null. Inheriting from CategoriesField should solve your issue.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Karl
    Karl avatar
    45 posts
    Registered:
    18 Jun 2009
    13 Jun 2011
    Link to this post
    Thanks, what namespace should I be using as its not allowing it at the moment.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    13 Jun 2011
    Link to this post
    Hi Karl,

    The namespace is Telerik.Cms.Engine.WebControls.Categories from Telerik.Cms.Engine assembly.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Karl
    Karl avatar
    45 posts
    Registered:
    18 Jun 2009
    14 Jun 2011
    Link to this post
    Hi,
    Thanks, now I get some other errors:
    BatchContentCategoriesField.LayoutTemplatePath': no suitable method found to override

    InitializeControls

    does not contain defination. and the list goes on.

    Do I need to change all tmy code post to work with this categories?
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    14 Jun 2011
    Link to this post
    Hi Karl,

    I am sorry the property is TemplatePath.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Karl
    Karl avatar
    45 posts
    Registered:
    18 Jun 2009
    14 Jun 2011
    Link to this post
    Hi,
    I get this now:
    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS0506: 'Telerik.Samples.BatchContentCategoriesField.TemplatePath.get': cannot override inherited member 'Telerik.Cms.Engine.WebControls.Categories.CategoriesField.TemplatePath.get' because it is not marked virtual, abstract, or

    Plus this won't solve the over errors on the attached.

    Also I've found it has to be called commonCategories for it to save before I even attempt to override it. If I call it Categories it won't save. In the templated provided by Telerik its titled

    commonCategories



    Thanks
Register for webinar
11 posts, 0 answered