Hide a WebPartZone based on whether multiple Repeater WebParts contain results

Keith Donnell asked on August 5, 2015 00:27

We have a zone with a header (editable text) and two Repeaters, each pulling different types of data and transforming them completely differently. We would like to hide the entire zone (including the text and any Before/After markup) if BOTH of these repeaters return no results. Is there a way to accomplish this, or is there another way to design the page so that the result is the same?

Recent Answers


Roman Hutnyk answered on August 7, 2015 05:02

javascript/jQuery should be the easiest I guess.

For repeater you might set Hide if no records found property to true.

0 votesVote for this answer Mark as a Correct answer

Maarten van den Hooven answered on September 24, 2015 22:46

Hi Keith,

What you can do is add an DIV around the zone with the two repeaters and an DIV around each repeater and then make the DIV around the zone invisible with jQuery.

Set Hide if no records found property to true on the two repeaters.

Her is an example of the jQuery and HTML you need to add:

<script>
    $('.ZoneContainer').not($('.RepeaterClass').parent()).hide();
</script>
<div class="ZoneContainer"> 
    <div class="RepeaterClass"><!-- Your first repeater --></div>
    <div class="RepeaterClass"><!-- Your second repeater --></div>
</div>

Hopefully you will succeed, if not please let me known if I can help.

If this answer helped you, please vote for my answer :-)

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.