0

I have encountered a problem with my previous question. The series of fields I do not want to display are not in the DispForm.aspx but in the modal dialog - I was under the impression the DispForm.aspx drove the modal dialog output. I dont think this is correct. Can someone advise please.

<asp:Content ContentPlaceHolderId="PlaceHolderTitleAreaClass" runat="server">
<script type="text/javascript" id="onetidPageTitleAreaFrameScript">
    if (document.getElementById("onetidPageTitleAreaFrame") != null)
    {
        document.getElementById("onetidPageTitleAreaFrame").className="ms-areaseparator";
    }
</script>
<SharePoint:ScriptLink runat="server" Name="/SiteAssets/js/jquery-1.10.1-min.js" Localizable="false"/>
<!--new script to hide empty form fields-->
<script type="text/javascript">
  $(function() {
    $.each($('td.ms-formbody'), function() {
      if (!$(this).text().replace(/\xA0/,' ').trim()) {
        $(this).closest('tr').hide();
      }
    });
  });
</script>

</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderBodyAreaClass" runat="server">
<SharePoint:StyleBlock runat="server">
1

As long as you have set your DispForm.aspx to be the Default form, this should stay true.

However do not forget that you do have 2 more forms used for new Items and Edit items, which might look the same, but they do behave differently.

Beyond this point, you should also check if you have many Content types and which one is by default, as it may happen to see a DispForm.aspx for any other content type in your list.

So basic line, via SharePoint Designer you should be able to see which forms are the default ones, by connecting to your list and using the forms section.

  • I have found my script is not working. I have added a script link to the min.js and code snippet to DispForm.aspx to hide my empty text fields. Unsuccesful. I have included my snippet above – garvon-77 Jun 25 '13 at 6:08
0

ANSWER FOUND! I have found my above question was answered effectively in a previous question

This code snippet does work along with the advice on how to place it.

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.