4

We are trying to do in this library, is create a column that will provide the “order” number of the listed item, per view.

So in one view there may be five items that show and they need to be numbered 1 through 5. Then in another view there may be 15 items that show and in this case they would need to display the numbering 1 through 15.

We have 12 views in total that would need the dynamic order numbering.

Please advise.

We are not able to use Visual Studio to work on this, only SharePoint Designer.

2 Answers 2

2

You can use SPD. On a page add the list view, then create a column and insert the following code:

<xsl:value-of select="count($thisNode/../*[not($thisNode/@ID=preceding-sibling::*/@ID)])" />

It should render the row number, no matter if you change the view order or filter some information.

Sample list

Hope this helps

1
  • this works perfectly when the number of items fits in one page. incase paging happens for the view the numbering again starts from 1 on subsequent pages ! Any idea how that can be fixed ?
    – Amol
    Commented Oct 7, 2015 at 8:19
1

I have a list MyTestList. It has currently two views TestView1 and TestView2. To add serial number in the front follow the following steps:

  1. Open the site in SPD
  2. Open the List enter image description here

  3. Edit the view in Split mode enter image description here enter image description here

  4. Select the List, Go to 'List View Tools' in the Ribbon > 'Design' > 'Customize XSLT' > 'Customize Entire View'
  5. This will convert the view in detail xslt
  6. Now click on the attachment column. Right Click > Insert > Column To The Left enter image description here
  7. Save the Page
  8. Come to the Browser, Go to the List and Go to the View
  9. Edit the Page of the View enter image description here
  10. Add a Content Editor WebPart in the Page. enter image description here
  11. Change the Content Editor Webpart's Chorme Type to 'None'. So web part's tool should not be shown in the page. enter image description here
  12. Click the Content Editor WebPart and go the HTML and paste the following lines showing in the Image to refer the Script.js and jquery-1.11.1.min.js. This will refer the Script, which will show the serial number enter image description here

  13. Go to the 'Site Assets' and upload jquery-1.11.1.min.js and Script.js which will contain the following code:

$(document).ready(function () {
    var count=0;
    $('.ms-listviewtable tr td:nth-child(2)').each(function( index ) {
                count++;
                $(this).text(count);
            });
});

Above steps needs to be repeated in all the views you have. Best of luck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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