1

I'm working with SharePoint 2013 and my Company don't allow the use of SharePoint Designer.

I have created a custom list and am looking to disable the column header filter from a number of the columns (e.g. the calculated columns).

I'm hoping someone can provide a code snippet, that I can apply to a script editor web part, which will help me achieve this.

Screenshot:

4
  • can you post screenshot what you need to disable? Jul 18, 2019 at 7:34
  • Hi Siddarth. Screenshot attached. I'm trying to disable the filter function on specific columns
    – user82126
    Jul 18, 2019 at 7:49
  • Hi Karthik. I saw that thread, but I couldn't get either of the options to work.
    – user82126
    Jul 18, 2019 at 8:14

1 Answer 1

0

As you mentioned you need to add script in script editor webpart.

Please note that you need to keep all columns which you want to disable handy.

Say for example my column name is 'Yes No' You need to form id of column header with below pattern, please note that diidSort2 is constant for each column and its appended with internal column name

'diidSort2' + [column internal name>]

For example my field internal name is 'MyMMDField' below script needs to be executed on document.ready

$("#diidSort2MyMMDField").parentNode.parentNode.removeAttribute("onmouseover")

I tried this using console, it is displaying filter option.

// A $( document ).ready() block.
$( document ).ready(function() {
    setTimeout(function(){ 
console.log($("#diidSort2Question1"));
$("#diidSort2Question1").parentNode.parentNode.removeAttribute("onmouseover")
}, 3000);
});
8
  • Thanks for the help Siddharth. It is appreciated. I'm not an expert coder by any means, but I've just tried adding the following snippet (as per your advice): <script> ... unfortunately the sort/filter function is still visible on the Question 1 column though. $("#diidSort2Question1").parentNode.parentNode.removeAttribute("onmouseover") </script>
    – user82126
    Jul 18, 2019 at 10:03
  • Sorry, that comment formatted slightly strangely. :) I added the script mentioned above but the sort/filter on the selected column wasn't disabled
    – user82126
    Jul 18, 2019 at 10:08
  • you have to wait till document is loaded, in fact you might have to give some delay also so that when code runs it find elements are rendered. Jul 18, 2019 at 10:12
  • Ok, still not working at my end. Thanks for the advice though.
    – user82126
    Jul 18, 2019 at 10:21
  • it should work,....did you try to debug whether code is getting executed, where element in console.log($("#diidSort2Question1"));...try to debug in console... Jul 18, 2019 at 11:18

Your Answer

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