More in this section
Categories
Bloggers
Blogs RSS feed

Removing child views from the View

by Ivan Osmak

[This post is part of the developer's manual preview published on this blog. You can find temporary TOC here.]

 
[This article requires Sitefinity 3.6 hotfix to be installed

 

In the article preceding this one, we have seen how one can add a brand new child view to a View. In this article we will do exactly the opposite. We are going to remove an existing child view from a View.
The principle for removing the child view is basically the same as for adding it, though instead of the add method, this time we will use remove method.

 

Scenario: cripple the Events module

 

Our ever demanding boss has decided that “Geomapping settings” has no business in the Events module and she wants it gone. Once we are done there should be no user interface command for accessing Geomapping settings, nor should there be any other way to access it. To refresh your memory and get a clearer picture of what are we about to do, take a look at the following image.

 


 

Implementation


As it was the case with adding a new child view, yet again we need an ability to access the child views collection of a host view in order to remove the view. Since we are working with the Events module this time, the root view which is the host to GeomappingSettingsView is EventsControlPanel.

 

To remove the GeomappingSettingsView, all we need to do is set the following declaration in our Controls Config file.

<?xml version="1.0" encoding="utf-8"?> 
<controlsConfig> 
  <viewMap> 
    <!--Root view of the Events module.--> 
    <viewSettings hostType="Telerik.Events.WebControls.Admin.EventsControlPanel"
      <views> 
        <remove name="GeomappingSettingsView`1" /> 
      </views> 
    </viewSettings> 
  </viewMap> 
</controlsConfig> 
 

As you can see, our logic is exactly the same as it was when we were adding a new view, but this time we are removing the View. 

 

14 comments

Leave a comment
  1. Romi Feb 25, 2009
    Hi, Thanks for this Manual on fly.
    Could you make this same issue codebehind. For sample if some user has role "Custom" remove pthis child view.
  2. Ivan Feb 25, 2009
    Hi Romi,

    yes, of course, it is possible to handle the Views in the code - Controls Config file is just an alternative. ViewModeControl (and ViewModeUserControl) base classes have a virtual Method "CreateViews" which is called to create child views. So in this method, you can implement various conditions such as user role in your example and decide which child View you will create and which one you will not. You can find more information on this subject in this article: http://blogs.sitefinity.com/Ivan/Posts/09-02-19/Sitefinity_3_6_new_backend_architecture_-_What_are_Views.aspx

    If you are looking for doing this for one of the built-in Views, you can apply the technique of replacing Views, which is described in this article: http://blogs.sitefinity.com/Ivan/Posts/09-02-25/Replacing_a_child_view_with_another_one.aspx . What you would do is basically, create a new implementation of the desired host View, override the CreateViews method and put your conditioning logic in there.

    I hope this makes sense.
  3. chris Jan 18, 2018
    This is truly a decent and enlightening, containing all data furthermore greatly affects the new innovation. A debt of gratitude is in order for sharing it  Freiburg
  4. Arnold Jan 18, 2018
    Appreciate it for this post, I am a big fan  of this website   would like to  continue  updated. neet 2018 application form
  5. chris Jan 20, 2018
    hi was just seeing if you minded a comment. i like your website and the thme you picked is super. I will be back. forskolin supplement side effects
  6. chris Jan 21, 2018
    This is a really decent site post. Not very numerous individuals would really, the way you simply did. I am truly awed that there is such a great amount of data about this subject have been revealed and you've given a valiant effort, with so much class. In the event that needed to know more about green smoke audits, than by all methods come in and check our stuff.  192.168.l.254 wifi password
  7. ronijames Jan 21, 2018
    if the buffalo in my head could speak german i would not know a god damm thing. What i do know is that the language of art is out of this world. tips
  8. chris Jan 23, 2018
    Amazing! This could be a standout amongst the most helpful web journals we have ever run over on thesubject. Really superb data! I'm additionally a specialist in this theme so I can comprehend your exertion.  sbothai8
  9. chris Jan 25, 2018
    Much obliged, that was a truly cool read!  https://www.aleksandrarussiandate.com
  10. chris Jan 29, 2018
    Much obliged for sharing us about this redesign. Trust you won't get tired on making posts as enlightening as this.  end milling
  11. chris Jan 30, 2018
    A debt of gratitude is in order for sharing the post.. folks are universes best individual in every existences of individual..they need or must succeed to manage needs of the crew.  tree-doctor-houston.com/kingwood.htm
  12. chris Jan 31, 2018
    I felt extremely upbeat while perusing this site. This was truly exceptionally useful site for me. I truly enjoyed it. This was truly a warm post. Much obliged!.  getfreestuffonlinenow.com
  13. breast enhancer pill Feb 01, 2018
    I  conceive you have  noted  some very interesting  details ,  regards  for the post. breast enhancer pill
  14. TriboTEX  Feb 06, 2018

    Leave a comment