locked
CRM 2011 Tab Height Resize automatically RRS feed

  • Question

  • On my Account form, I have a tab, which has 10 fields, but only 1 field is visible.

    On the onchange event of the field, if Field1 contains value, field2 will be visible, and so on. . . up to field 10.

    Now the question is,

    when only 1 field is visible, there is a lot of unused space below, since fields 2 - 10 are hidden..

    Is there a way of dynamically resizing the size/height of the tab? (Just to avoid the big gaps/unused spaces)

    Thanks!

    (Note: I am using CRM 2011 OnPremise RU 13)

    Monday, August 19, 2013 2:37 AM

Answers

  • 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".

    Twitter LinkedIn Facebook Blog Magnetism


    Tuesday, August 20, 2013 6:54 AM