SharePoint JSLink – disable the filter and sorting pane on list view headers

I had the requirement to disable the functionality to sort and filter on column headers in the list view. I could not find a lot about it online so here is my solution using CSR/JSLink and Jquery


(function () {
var Context = {};
Context.OnPostRender = disableHeaderFilter;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(Context);
})();

function disableHeaderFilter(renderCtx)
{
var linkTitleField = renderCtx.ListSchema.Field[5];
$("div[name="+ linkTitleField.Name + "]").parent().replaceWith('<th class="ms-vh2">' + linkTitleField.DisplayName + '</th>');
}

The 5 in the code is the column number order in the header

Tags :

2 thoughts on “SharePoint JSLink – disable the filter and sorting pane on list view headers”

  1. Eliezer says:

    Great! it was helpful for me. Thanks for sharing

  2. I see you don’t monetize your website, don’t waste your traffic, you can earn extra
    cash every month because you’ve got hi quality content.
    If you want to know how to make extra bucks, search for: Mertiso’s tips best adsense alternative

Leave a Reply to Eliezer Cancel reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>