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("&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: WSS,MOSS,Table,Cell,Borders,SharePoint,DataFormWebPart,Designer,script,forces,Here,text,Cells
Windows Live Tags: WSS,MOSS,Table,Cell,Borders,SharePoint,DataFormWebPart,Designer,script,forces,Here,text,Cells
David christianson
/ April 11, 2011Thanks Jason! This fixed a report some of my folks needed for printing. Great help!!!
Jason Graham
/ January 17, 2012Hi, David. Glad to hear this helped! Sorry to see that I never got a notification that you commented.
Jozef Ozimy
/ November 22, 2012THANK YOU ! You helped me a lot 🙂
Jason Graham
/ November 22, 2012Glad to help. 🙂