1

I am creating two views of a 'News' List.

  1. The First View displays the most recently added item to the list.
  2. The Second View needs to display the 2nd, 3rd and 4th most recently added items.

Is there a way from within the Edit View screen, to skip the first row of a queried list?

(I am trying to render these views from within ShortPoint elements, so a normal Content Query or Content Search related solution will not work)

0

P-Bagles,

Although I am not 100% sure if this is the best way to achieve this (you may look into JSLINK CONDITIONS), this method does meet the requirement that you are looking to achieve, with some small caveats in regards to sorting, etc.

Here is how you can achieve this.

COUPLE IMPORTANT NOTES for the LISTED code:

  • *IMPORTANT:::: YOU WILL NEED TO CHANGE #scriptWPQ2 to the webpart ID that is on your page, you can do an inspect element to find the web part ID
  • The tr:eq(2) part of the code will hide the FIRST row item ONLY in the list, if you want to hide additional ones you will replicate this line of code and add additional tr:eq(3), tr:eq(4) (EXAMPLE AT THE BOTTOM), you will need a new .html for each views PAGE with a content editor linked to each .html file ON EACH PAGE!*

SOLUTION:

  1. Create your views, each view will get its own .aspx page
  2. In your site assets library create a .html file and put this code

THE CODE for html file(s):

    <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

    <script type="text/javascript">
    $(document).ready(function(){

// IMPORTANT:::: YOU WILL NEED TO CHANGE #scriptWPQ2 to the webpart ID that is on your page, you can do an inspect element to find the web part ID
// This tr:eq(2) will hide the FIRST row item ONLY in the list, if you want to hide additional ones you will replicate this code, you will need a new .html for each view with a content editor linked to each .html file
        $('#scriptWPQ2 tr:eq(2)').hide();
        //$('#scriptWPQ2 tr:eq(3)').hide();
        //$('#scriptWPQ2 tr:eq(4)').hide();
        //$('#scriptWPQ2 tr:eq(5)').hide();
    })
    </script>
  1. Save the html file with a .html extension
  2. Add a content editor to each views aspx page and link it to each corresponding .html file (i.e. hide1row.html hide2rows.html)

Again, here is an example of hide1row.html

    <script type="text/javascript">
    $(document).ready(function(){
        $('#scriptWPQ2 tr:eq(2)').hide();
    })
    </script>

AND FOR hide2rows.html (notice there is 2 .hide() commands)

    <script type="text/javascript">
    $(document).ready(function(){
        $('#scriptWPQ2 tr:eq(2)').hide();
        $('#scriptWPQ2 tr:eq(3)').hide();
    })
    </script>

INSPECT ELEMENT ON PAGE

SNIPPET OF CODE IN SHAREPOINT DESIGNER

Understanding this is a big workaround, once you get the hang of it, it should be pretty easy to achieve and replicate.

Good Luck!

  • If you are already loading in jQuery to your sharepoint site then you can omit the <script src="jquery CDN link"> in the code. Just a heads up. – SP-Kyle Jul 12 at 18:18
  • Thanks! I will try this out!! And report back on what happens (: – P-Bagels Jul 13 at 22:04
  • Great, let us know :) – SP-Kyle Jul 17 at 16:09
  • 1
    This worked really well. I had to change it up a bit to specifically target the elements I needed, but the concept of simply hiding the elements is really simple and straight forward, thank you! – P-Bagels Jul 18 at 16:24
  • Glad that it worked for you! Woop! :) – SP-Kyle Jul 18 at 16:39

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.