Hide blank readonly fields?

Forums Dynamic Forms for SharePoint Hide blank readonly fields?

Tagged: 

This topic contains 4 replies, has 3 voices, and was last updated by  becca 3 months ago.

  • Author
    Posts
  • #21652

    Keith Hudson
    Participant

    I would like to hide any readonly fields that have no value in them. I’ve tried several approaches, none of which have worked yet.

    Is there code I can use to do so?

  • #21685

    Alexander Bautz
    Keymaster

    Hi,
    You can use something like this to hide the empty fields in your current tab:

    jQuery.each(spjs.dffs.data.tabConfigObj[spjs.dffs.data.selectedTab].fields,function(i,id){
    	if(id.indexOf("dffsHeading_") < 0 && id.indexOf("dffsHTML_") < 0 && id.indexOf("dffsRow_") < 0){
    		var tr = jQuery("#dffs_" + id);
    		if(tr.hasClass("dffs-readonly") && getFieldValue(id).length === 0){
    			tr.hide();
            }
        }
    });

    Alexander

  • #25238

    becca
    Participant

    Is there anything in this code that needs changed based on our specific lists? With the code as written I get an error “Cannot read property ‘0’ of undefined”

    **I am not checking for read-only, only blank

    • This reply was modified 3 months, 1 week ago by  becca.
  • #25245

    Alexander Bautz
    Keymaster

    I’m not sure what it could be – can you share the modified code you are using?

    Alexander

  • #25297

    becca
    Participant

    I apparently never hit Submit when I typed this out before, my apologies.

    I ended up just copying your code character for character but it still didn’t work. I’m switched off this project for now so this can be ignored for a bit. My team has made me the de facto SharePoint expert working on multiple projects so my focus is being switched/refocused often, thus all the very different asks that don’t always have the best follow-up; sorry spastic-ness and thanks for all the help so far.

You must be logged in to reply to this topic.