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

Forums / Developing with Sitefinity / Perfomance of categories tree

Perfomance of categories tree

7 posts, 0 answered
  1. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    29 Jan 2010
    Link to this post

    Hi!

    I have a lot of categories for some modules on my site: generic content (200 categories), libraries (150 categories). Perfomance of admin's interface is very bad when I try to open categories tree of this module. How can I increase perfomance for this part of admin's interface?

    Thank you.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    29 Jan 2010
    Link to this post
    Hi Paul,

    The problem is related to the categories count, so the browser output is very large. The way that the categories are bound is not so optimal

    What you can do

    1. Replace the bacend view for the desired module (modules). The view is called CategoriesView.
    2. Create a custom view that inherits from CategoriesView
    3.  Rebind the categories RadTreeView control and remove the counter.

    sample code:

    protected override void RenameCategory(Guid categoryId)
    {
        RadTreeNode node = this.CategoriesTreeView.FindNodeByValue(categoryId.ToString());
        ITextControl categoryName = (ITextControl)node.FindControl("categoryName");
        if (categoryName == null)
            throw new Exception(String.Format(cannotFindControl, "categoryName",
                                              "gridCategories ItemTemplate"));
         
        ICategory category = this.Host.Manager.GetCategory(categoryId);
     
        if (this.Host.Manager.GetCategory(categoryName.Text) != null && category.CategoryName != categoryName.Text)
        {
            base.Message1.Message = categoryExists;
            base.Message1.Mode = MessageMode.Error;
            ChildControlsCreated = false;
            return;
        }
     
        // reassign all content which has the the old category name
        // to the new category name
        this.Host.Manager.UpdateContentCategory(category.CategoryName, categoryName.Text);
     
        category.CategoryName = categoryName.Text;
        if (!string.IsNullOrEmpty(this.ParentCategoriesList1.SelectedValue))
        {
            if (category.ParentCategoryID != new Guid(this.ParentCategoriesList1.SelectedValue))
                EnsureHierarchyIntegrity(category, new Guid(this.ParentCategoriesList1.SelectedValue));
            category.ParentCategoryID = new Guid(this.ParentCategoriesList1.SelectedValue);
        }
        else
            category.ParentCategoryID = Guid.Empty;
     
        this.Host.Manager.SaveCategory(category);
        BindCategories();
    }
     
    protected override void DeleteCategory(Guid categoryId)
    {
        base.DeleteCategory(categoryId);
        this.categories = null;
    }
     
    protected override void BindCategoriesList(RadComboBox comboBox, Guid? selectedCategoryId, Guid? disabledCategoryId)
    {
        comboBox.MarkFirstMatch = true;
        comboBox.AllowCustomText = false;
     
        if(this.categories == null)
            categories = this.Host.Manager.GetCategories(0, 0, "CategoryName");
     
        RadComboBoxItem liSelectNone = new RadComboBoxItem();
        if (selectedCategoryId == Guid.Empty)
            liSelectNone.Selected = true;
        liSelectNone.Text = none;
        liSelectNone.Value = string.Empty;
        comboBox.Items.Add(liSelectNone);
     
      //
     
    }


    2. Wait for no more than week or two and check our blog where I will post the code. 

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    11 Feb 2010
    Link to this post

    Hi Ivan!

    When will you write in blog about optimization of categories tree perfomance?

    Thank you.

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    11 Feb 2010
    Link to this post
    Hi Paul,

    I will try to do it this weekend. I'm sorry for the delay. If you are on a hurry you could follow the steps in my previous post to optimize the performance.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  5. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    11 Feb 2010
    Link to this post

    Hi Ivan!

    Can you describe first and second steps more clearly? I want to create custom control for Generic Content module. What do I need replace and change?

    Thank you.

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    11 Feb 2010
    Link to this post
    Hello Paul,

    1. Replace view - Replacing a child view with another one
    2. Create a custom view

    public class CategoriesViewCustom : CategoriesView
    {
        public CategoriesViewCustom()
        {
     
        }
     
        public override string LayoutTemplatePath
        {
            get
            {
                return "~/CustomTemplates/CategoriesView.ascx";
            }
     
        }
     
               ....
                 ....
    }


    Best wishes,
    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.
  7. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    11 Feb 2010
    Link to this post

    Hi Ivan!

    I try to reproduce this steps but I can't understand how and what I need replace. And your code snippet doesn't work for me =(

Register for webinar
7 posts, 0 answered