SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to add a custom JavaScript link to my SharePoint list, so it would only affect that list. I don't need to add it to any other forms. How could it be done?

I was thinking, if to change .aspx file, where the list sits (if it is possible), if this is a good idea, then where can I find that file?

EDIT: I need this to pin my top row (column names) to top of browser view, so I wouldn't lose them, when user scrolls to bottom of page.

share|improve this question
    
Why do you need that? This could help to brind you an answer. – jpussacq yesterday
    
Edited my question – Taurib yesterday
2  
JSLink or adding a script editor on the views .aspx page are good ways for doing this – Robert Lindgren yesterday
    
How to I add script editor to my view in list. When I try it through designer, then it won't change anything – Taurib yesterday
1  
if you want to change the display of the data, you surely want check CSR Client-Side Rendering, see this link for more information. – Mauricio yesterday
up vote 3 down vote accepted

You might do as follows from the browser:

  • Edit the list page from top right gear/edit page
  • Add new web part/Script Editor to the page
  • Add your javascript code
share|improve this answer
    
Oh yeah, thanks! Forgot to look for edit page from there at all.. – Taurib yesterday

I usually use either a script editor web part or a content editor web part.

If you want to create sticky headers in a SharePoint list, I've been using the below library and have been pretty happy with the results.

http://spoodoo.com/sticky-headers-in-sharepoint-2013/

All you have to do to implement is throw a copy of the sticky headers js file and a copy of jQuery in a script editor above the list view and you'll magically have a fixed header when you scroll the list view.

share|improve this answer
    
Thanks for the answer, I was looking at the same solution! :) – Taurib yesterday

1) Edit the page of the view

2) Add a Content Editor Web Part

3) Link this CEWP to a file containing JavaScript and CSS

4) Store this file in a SharePoint Document Library

Sample: https://ybbest.wordpress.com/2013/01/15/how-to-use-html-and-javascript-in-content-editor-web-part-in-sharepoint2010/

share|improve this answer
    
Thanks for the answer, forgot about edit page under gear symbol – Taurib yesterday
1  
Steps 3 and 4 are very importante to separate the code and easy editing. – jpussacq yesterday

The "CEWP" approach is Ok. But you need to remember that EVERY LIST VIEW creates a "new" .aspx page.

So, "AllItems.aspx", will receive a CEWP with you JS. Your list have a "MyItens.aspx" view? Another CEWP.

Be aware of this point and good luck!

share|improve this answer
    
Oh, thanks for pointing that out! – Taurib yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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