We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Hide column in filterbar?

I know I can disable a filterbar for a column by setting AllowFiltering = false for that single column but is there a way to not show the filter field at all in the filterbar for a particular column?


3 Replies

JC Joseph Christ Nithin Issack Syncfusion Team March 14, 2023 07:10 PM UTC

Hi Scott,


  Greetings from Syncfusion support.


  Based on your query, you want to hide the filterbar if the filtering is disabled for the particular column. Your requirement can be achieved in the created event of the EJ2 Grid.


Please refer the below code example:


 

function created() {

    var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];

    var filter = grid.element.querySelectorAll('.e-filterbarcell');

    var columns = grid.getVisibleColumns();

    for (var i = 0i < columns.lengthi++) {

      if (!columns[i].allowFiltering) {

        filter[i].querySelector('.e-input-group').classList.add('e-hide');

      }

    }

  }

 


Regards,

Joseph I.



SC Scott replied to Joseph Christ Nithin Issack March 15, 2023 01:22 PM UTC

Thank you Joseph.  I ended up going the route of a search bar instead for now but this website is for my wife and she may still end up wanting the individual filters, in which case I will use your example, which looks to make perfect sense.  Appreciate your assistance.



JC Joseph Christ Nithin Issack Syncfusion Team March 16, 2023 02:29 PM UTC

Scott,


   We are glad that the provided solution resolved your query.




Loader.
Live Chat Icon For mobile
Up arrow icon