Im currently working in SharePoint 2007 Page Layout, I have Site Columns created to be drag and drop into custom page layout via SharePoint Designer 2007.

The Site Columns is not required field, if the column is not fill in value, I expected it does not consume any spacing in display view of the page.

Example: arrange 5 columns vertically in page layout, if no value fill in, it consumed 5 empty rows.

Any workaround to hide away the empty space when no value fill into the column? Thank you in advanced.

1 Answer 1


Use 2 edit mode panels. One with PageDisplayMode set to edit and the other to display. In the display mode, wrap your field with a div and give it an Id. Check with jQuery if empty like following:

$.trim($('#div_id').text()) == ""

then hide the div if so.

Or, if you don't like hiding with JS. place a visual webpart in the display mode of the EditModePanel, and through the object model get the values of the fields and send to the client only the HTML that contains data in whatever format you like.

  • Hi Mohammed Shokry, thanks for your reply, from your solution, when the field is empty, there is a default '  ' (with spacing after  ) value added automatically by SharePoint, just why need to trim away the white space and then hide the div. Is there any better solution rather than hide?
    – sams5817
    Commented Mar 5, 2012 at 8:07
  • Let say I have <tr><td id="A"></td><td id="B"></td></tr>, when I check ID=A is empty, this may caused column with id=B align to the left
    – sams5817
    Commented Mar 5, 2012 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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