In the past, I had used this code to hide a row in a SharePoint Edit Form (EditForm.aspx):
$('nobr:contains("Attendees")').closest('tr').hide();
The problem with this is that if you have two fields that contain the text “Attendees” (For example “NewAttendees” & “OldAttendees”), then it matches both of them (this always seems to to be an issue for us). So I did a little research and I found a better way to select a row (I think this was my original source)
Here is my new/better way to match a row:
$('nobr').filter(function () { return $(this).text() === 'Attendees' }).closest('tr').hide();
If it was a required field, it would be:
$('nobr').filter(function () { return $(this).text() === 'Attendees *' }).closest('tr').hide();
Hope that helps someone.
Even better, make yourself a little utility function so that you can call it for multiple columns. This one works whether the column is required or not. You never know when someone might tick that Required box!
function hideRow(c) {
var x = $(“.ms-formlabel nobr”).filter(function () {
return $(this).contents().eq(0).text() === c;
}).closest(“tr”).hide();
}
hideRow(‘epaProgress’);
M.
Great idea! Thanks.
How do you go about hiding a row that doesn’t have any hard coded text to reference in the nobr code?
I’m new to jquery and I’ve edited my userform to utilize the field description instead of the FieldName, but I can’t figure out how to reference the field description as the row to hide.
Any help appreciated.
Very helpful, thanks!