Adding Table Cell Borders to Empty Cells in a SharePoint DataFormWebPart

If you’ve ever used a DataFormWebPart in SharePoint Designer 2007 with a border on the table, then you may have run into the problem of empty table cells loading without borders.  This causes your table to look very strange in the browser.  Well, here is a fairly simple work around to fix the problem.  All you need to do is add a script block to the xslt in SharePoint Designer that will basically put a space inside all of the cells.  Since this forces the cells to not be empty, they will all render with borders.

Here is the script block and some quick screenshots to demonstrate how it works.

<script type="text/javascript">
    document.write("&amp;nbsp;");
</script>

Here is how the table will render without the script block if there are empty cells:

Add the script block inside of the td’s just after the xsl:value-of tags that contain the SharePoint field names that you have included in your DataFormWebPart:

Here is what the new page with blank cells should look like:

Technorati Tags: ,,,,,,,,,,,,

Windows Live Tags: WSS,MOSS,Table,Cell,Borders,SharePoint,DataFormWebPart,Designer,script,forces,Here,text,Cells

Advertisements
Leave a comment

4 Comments

  1. Thanks Jason! This fixed a report some of my folks needed for printing. Great help!!!

    Reply
  2. THANK YOU ! You helped me a lot 🙂

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: