Show/Hide Table on Custom Page Layout

Hi All,

I have a custom layout page. I have a number of table on it.

When I edit the page, it should show all the tables. When on display mode, it should only show the table whose td is not blank i.e empty.

Has anybody come across this scenario? Your help is higly appreciated.

Thanks & regards,

Manish

January 14th, 2014 5:33am

hi

define javascript variable inside EditModePanel on page layout:

<PublishingWebControls:EditModePanel ID="EditModePanel3" runat="server">
<script type="text/javascript">
    var isEditMode = true;
</script>
</PublishingWebControls:EditModePanel>

after that hide tables via jQuery:

$("table").each(function(){
    if (isEditMode) {
        return;
    }

    var isEmpty = true;
    $(this).find("td").each(function(){
        if ($(this).html() != "") {
            isEmpty = false;
        }
    });

    if (isEmpty) {
        $(this).hide();
    }
});
This is basic idea. I didn't tested the code above, so you will need to adjust it for your case.
Free Windows Admin Tool Kit Click here and download it now
January 14th, 2014 5:51am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics