0

Is there any way of targeting a single column in a document library?

I am wanting to apply CSS to just the Name (linked to document with edit menu) column (through a Script Editor or via the Masterpage, I don't mind as it will be needed for all libraries that are created within this site.

0

Based on your previous posts (this post and this post), you display the menu ellipsis (...) for the last column in the view and want to hide the menu ellipsis for the Name (linked to document with edit menu) column.

In this scenario, the menu ellipsis for the Name (linked to document with edit menu) column is the first one. You can use the JavaScript to hide the first menu ellipsis (...) in the view.

Demo:

enter image description here

Use the scripts below on the page:

<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("ready");
function ready(){
    var links = document.getElementsByClassName("ms-list-itemLink");
    for (var i=0; i<links.length; i++){
        // there are two link cells
        // get first link for each row
        if (i%2 == 0){
            links[i].style.visibility = "hidden";
        }
    }
}
</script>

Result:

enter image description here

  • Thanks Joanna - I've attempted to embed this in my page and it doesn't seem to be taking affect. Any idea as to why this might be? – AlyshaK Feb 19 at 3:16
  • Change ".hidden()" to ".style.visibility = 'hidden'". Check the edited answer – JoannaW_MSFT Feb 19 at 7:01
  • Thanks!! Finally something has worked - you're a legend :) – AlyshaK Feb 19 at 22:08
  • is there any way to add this to the materpage so it is picked up on all document libraries in this site? – AlyshaK Feb 20 at 0:28
  • Yes, you can. Place the script under <asp:Content contentplaceholderid="PlaceHolderMain" runat="server"> tag in the master page. And then publish the master page. – JoannaW_MSFT Feb 20 at 2:08
0

Yes, You can do it via JS Link for List View. This tutorial learn SharePoint Templates for Views and for Forms(new/display/edit) very deeply and comprehensive. I strictly advise you to consider full reading of them.

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.