0

Is there a way to hide web parts on a page conditionally. I have two views set up in an infopath browser enabled form (edit view). When I select a button to go to another infopath view I want to hide the additional web part that is attached to the page and of course show it again when I return to the original Infopath view. I'm Using SharePoint Enterprise 2010. Thank you.

2

You can accomplish that using jquery. The idea is on page load to see if a field exists. This field should exist in view1 and not in view2. Let's name it Field1. If Field1 exists, hide the webart

Add for ajax to the page or the master page or in a script editor.

Next install firefox+firebug.

Open the infopath form in browser, rightclick on the webpart you want to hide/inspect element with firebug. Go up the DOM until you find a div with an ID that contains the webpart you want to hide. Let's name it webpart_ID.

Go to the field field1/rightclick inspect element with firebug/ and write down the id. Let's name it Field_id.

Add a script editor and write:

$(document).ready( function() {
   var webpart_ID =  'the webpart_Id';
   var Field_id = 'the Field_ID';
   if ($('#'+Field_id).length!=0)
       $('#'+webpart_ID).hide();
   else $('#'+webpart_ID).show();
    });

if your knowledge in jquery is minimal, you can ask questions in stackoverflow

  • This answer lacks details and is more a comment than an actual answer. Can you please add some skeleton of jQuery code for hiding Webparts to at least give an idea of how to use it? – Robert Lindgren Sep 3 '14 at 17:46
  • 1
    Guess it's better now. – XristosK Sep 3 '14 at 21:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.