Display Form hide fields

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
gleegeld
Posts: 13
Joined: Tue Jun 30, 2015

04 Aug 2015

Hello,

Is it possible to only display fields on the display form that have content/value?

I have been playing with something like this but I haven't had any luck.

$.each($('.fd_control'), function () {

if (!$(this).val()) {

$(this).closest('.fd_field').hide()

}

});



Thanks

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

05 Aug 2015

Please use the following function:

Code: Select all

$.each($('.fd_control'), function () {
        if
(!(/\S/.test(fd.field($(this).closest('.fd_field').attr('fd_name')).control(
)._el().text()))){
                $(this).closest('.fd_field').hide();
        }
});

gleegeld
Posts: 13
Joined: Tue Jun 30, 2015

11 Aug 2015

That worked perfectly! thanks so much

gleegeld
Posts: 13
Joined: Tue Jun 30, 2015

12 Aug 2015

Hi,

This code work great on one of my list. However when I apply it to another list. Everything is hidden, even fields with a value, the display is set to none.

Here is an field that has content but is getting hidden

<td style="padding: 5px; width: 100%;"><div class="fd_field " style="height: 27px; display: none;" fd_name="Copies"><div class="fd_title" style="width: 50px; white-space: nowrap;">Copies</div><div class="ms-formbody fd_control" fd_type="Text" fd_readonly="True">2</div></div></td>


Any idea as to why it is hiding this field?


Thanks

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

13 Aug 2015

I copy-pasted in your element and the code works as expected. The " display: none;" part the of the style attribute - is it there before the code is run?
If not, please send us the html of your display page to support@spform.com .

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

26 Aug 2015

Thanks, maybe I copied something wrong. It is now working for me.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 18 guests