When you use lookup to the list automatically
SharePoint give link to the lookup item on list view.
Check it out….
Lookup column with Hyperlinks
But many times, we don’t want those Hyperlinks on
the list view, as we can remove it from SharePoint Designer but it’s a hectic
task.
Simply add JQuery to remove those
Hyperlinks.
First, get the URL of the link using Developer tool
of IE or Firebug of Firefox browser. we are going to some part of URL in the
below code.
//Get all the Created By column Anchor tags with href contains url part.
$('a[href*=http://syntel.sharepoint.com/TeamSite/asentech/_layouts/listform.aspx]').each(function () {
var className = $(this).parent().attr("class"); // Get Class Name of Parent Element i.e <td>
//Check class name = ms-vb for safety, because may it unfortunately replace navigation links.
if (className == 'ms-vb') {
var innerText = $(this).text(); // Get Anchor tag inner text
$(this).parent().html(innerText); // Replace Parent tag inner html to Anchor tag text. It will replace Anchor tag.
}
});
}
catch (err) { alert(err); }
}
</script>
<script type="text/javascript">
$(document).ready(function () {
Removelink(); // Call to Removelink function on Page Load
});
// ExpGroupRenderData overwrites the default SharePoint function. This part is needed for collapsed groupings
function ExpGroupRenderData(htmlToRender, groupName, isLoaded) {
Removelink(); // Call to Removelink function on Page Load
}
</script>
Get URL using Developer tool of IE
Then copy following JQuery code to the HTML form
WebPart on list view.
Jquery For SharePoint 2010/SharePoint Foundation 2010:
Jquery For SharePoint 2010/SharePoint Foundation 2010:
<script type="text/javascript">
//This script is developed by Mohammad Yusuf Hussain # http://mohammadyusufhussain-sharepoint.blogspot.in/
_spBodyOnLoadFunctionNames.push("Removelink");
function Removelink() {
try {
function Removelink() {
try {
//Get all the Created By column Anchor tags with href contains url part.
$('a[href*="http://syntel.sharepoint.com/TeamSite/asentech/_layouts/listform.aspx"]').each(function () {
var innerText = $(this).text(); // Get Anchor tag inner text
$(this).parent().html(innerText); // Replace Parent tag inner html to Anchor tag text. It will replace Anchor tag.
});
}
catch (err) { alert(err); }
}
</script>
var innerText = $(this).text(); // Get Anchor tag inner text
$(this).parent().html(innerText); // Replace Parent tag inner html to Anchor tag text. It will replace Anchor tag.
});
}
catch (err) { alert(err); }
}
</script>
Note:
Change highlighted text as per your context.
Jquery For MOSS
2007/WSS 3.0:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
//This script is developed by Mohammad Yusuf Hussain # http://mohammadyusufhussain-sharepoint.blogspot.in/
function Removelink() {
try {
//Get all the Created By column Anchor tags with href contains url part.
try {
//Get all the Created By column Anchor tags with href contains url part.
$('a[href*=http://syntel.sharepoint.com/TeamSite/asentech/_layouts/listform.aspx]').each(function () {
var className = $(this).parent().attr("class"); // Get Class Name of Parent Element i.e <td>
//Check class name = ms-vb2 for safety, because may it unfortunately replace navigation links.
if (className == 'ms-vb2') {
var innerText = $(this).text(); // Get Anchor tag inner text
$(this).parent().html(innerText); // Replace Parent tag inner html to Anchor tag text. It will replace Anchor tag.
}
});
if (className == 'ms-vb2') {
var innerText = $(this).text(); // Get Anchor tag inner text
$(this).parent().html(innerText); // Replace Parent tag inner html to Anchor tag text. It will replace Anchor tag.
}
});
//Get all the Created By column Anchor tags with href contains url part.
$('a[href*=http://syntel.sharepoint.com/TeamSite/asentech/_layouts/listform.aspx]').each(function () {
var className = $(this).parent().attr("class"); // Get Class Name of Parent Element i.e <td>
//Check class name = ms-vb for safety, because may it unfortunately replace navigation links.
if (className == 'ms-vb') {
var innerText = $(this).text(); // Get Anchor tag inner text
$(this).parent().html(innerText); // Replace Parent tag inner html to Anchor tag text. It will replace Anchor tag.
}
});
}
catch (err) { alert(err); }
}
</script>
<script type="text/javascript">
$(document).ready(function () {
Removelink(); // Call to Removelink function on Page Load
});
// ExpGroupRenderData overwrites the default SharePoint function. This part is needed for collapsed groupings
function ExpGroupRenderData(htmlToRender, groupName, isLoaded) {
Removelink(); // Call to Removelink function on Page Load
}
</script>
Note:
Change highlighted text as per your context.
If View is Grouped, set list view setting
"By default, show groupings:" to Expanded
List View setting: Make sure that By default, show groupings:
Expanded
List view with removed hyperlinks to Lookup
columns:
No comments:
Post a Comment