I take it you're using the supported way to hide fields:
Xrm.Page.getControl("new_fieldname").setVisible(false);
This method simply sets the element visibility to 'hidden', which doesn't actually remove it from the flow of the form, rather it just hides it... This is why you have all the wasted space.
If you want to completely remove the hidden fields from the flow of the form (and remove the wasted space) you will need to use some unsupported JavaScript to set the style.display="none" instead of using .setVisible().
Here is an example of what you can use:
function setFieldVisible(fieldName, isVisible) {
document.getElementById(fieldName + "_c").style.display = isVisible ? "" : "none";
document.getElementById(fieldName + "_d").style.display = isVisible ? "" : "none";
}
The first bit hides the label element, and then second bit hides the actual field/textbox element.
Edit: Also important to note, if there is a field to the right of the field being hidden, it will shift across. If the field is the only field on the row (or if all other fields are also hidden) the row below
will shift up.
Hope that helps
Paul
If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".
