4

I have a list that I need to dynamically hide columns on based on user. Sort of a rudimentary Column Level security type deal. This is being done through Javascript and JQuery to simply not display certain columns when certain logic is met.

Here's the code I currently use to hide a column:

var index = $("tr.ms-viewheadertr th:contains('"+ colName +"')").first().index()+1;
$('th:nth-child('+index+'),td:nth-child('+index+')').hide();

This works perfectly for List views without grouping, but several of the views have multiple groupings and I can't figure out how to make it hide in those sub groups. Anyone know of a work around?

  • Did you resolve this? I am encountering the same issue. – Aaronster Oct 25 '13 at 14:27
  • I don't have an answer for this but the code you put up to hide columns in views was really helpful, thanks – Batman Apr 5 '17 at 4:06
1

I have the same problem that you have and the solution for your problem is here

To it i used the codes below:

<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.js" type="text/javascript"></script><script type="text/javascript">$(document).ready(function(){$('td:nth-child(Column Number),th:nth-child(Column Number)').hide();});</script>

And:

<style type="text/css">.ms-vb-title{display:none !important;}</style>

Hugs

  • Please add a full description of the solution to your answer. If the link you provided breaks in the future, your answer will no longer be helpful. Thanks! – Phil Greer May 14 '14 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.