Hello everyone!
I want to hide multiple columns with all their rows followed by those columns
(Comments,Test1,Test2,Test5) in my list based on a specific group permission.
Here is a screenshot:
I have a found a jQuery code but it's based on hiding last column in the list and last cell.
I tried to find the position of the others column by inspecting the element for i add them to my code but i am stuck their.
Here is my jQuery code:
<script src="https://code.jquery.com/jquery-1.11.0.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.01/jquery.SPServices.min.js"></script><script language="javascript" type="text/javascript">
$(function () {
var currentUser = $().SPServices.SPGetCurrentUser();
console.log(currentUser);
$().SPServices({
operation: "GetGroupCollectionFromUser",
userLoginName: currentUser,
async: false,
completefunc: function (xData, Status) {
var flag = ($(xData.responseXML).find("Group[Name='Dev Site Add-ins Members']").length == 1);
if (flag) {
//To Hide Column Header
document.querySelector("div[name^='Comments']").parentElement.style.display = "none";
// To Hide all rows for the Comments column
var tdElementsNodeList = document.querySelectorAll("td[class^='ms-vb-lastCell']");
for (var i = 0; i < tdElementsNodeList.length; i++) {
tdElementsNodeList[i].style.display = "none";
}
}
}
});
});</script>What would be the code to hide those columns i mentioned above?
Any help will be greatly appreciated.
Thank you!