SharePoint 2013 Script to update Title link with URL and ID

SharePoint 2013 Script to update Title link with URL and ID

So I needed to create a list data view and have the items title link to a fixed URL path with the item’s ID at the end as a query string parameter.
In SharePoint 2010 I would get this done in SharePoint Designer, adding an empty data view
and editing its XSL.
In 2013 I wanted to do this using JSlink but I found it more complicated than I thought it would be, and I was short on time, so I wrote this simple script that grabs the ID from the last column of the data view and updated the href attribute of the first data view column –

{code type=javascript}

{/code}

In order to get the above script to work make sure:
1. Your SharePoint site has a jQuery reference.
2. Your Data View first column is the title or any other column you want to use as a link.
3. Your Data View last column is the item’s ID.
4. Update the variable “urlPath” with your own path.
5. Update the variable “listName” with your own list’s name.

SharePoint Data View XSLT Tips and Tricks – Limit text field

SharePoint Data View XSLT Tips and Tricks – Limit text field

Here is an XSLT syntax used to limit the number of characters of a text column (in this example the title field), In case the text is more than 50 characters long this function will substring it from the start and up to its last occurrence of a white space and add 3 points after it –
{code type=html}

{/code}

If you don’t mind your text being cut off after the limited number of characters you could use this shorter XSLT syntax –
{code type=html}

{/code}


To count how many characters can fit your designated area you can use this nice online tool.

SharePoint Data View XSLT Tips and Tricks - Limit text field

Ellipsis

This is a cool trick to use, but if your text field should fit into one row only, you shouldn’t bother with it and it will be smarter to use this CSS Truncate String with Ellipsis technique which is supported in almost all browsers (even by IE8 believe it or not!).