Add filter buttons keep coming back!?

Hello! I have been having an issue for about 6 months where the add filter button option keeps showing back up on my app! Its absolutley crazy. Sometimes when I go into the settings to remove it, it’s even unchecked! but still showing on the page.

  • I have gone in and deleted them and a few days or a month later they re-appear, over and over
  • This is happening to me site-wide, meaning on pretty much every page of the app!
  • I have worked in detail with Knack and they simply have said they can’t figure it out

So, I am just wondering if anyone else is having this issue. Seems so bizarre to me :face_with_peeking_eye:

1 Like

Ha! Yes, I have experienced this issue too. Until there’s a fix, I’ve worked around it by hiding the filters with CSS.

Ian

oooh please share the css!

Glad to know I’m not alone - I think, sorry :smile::smile:

You can use one of these approaches, depending on how many views you want to target.

/* Hide filters on specific views */
#view_1 .kn-filters-nav,
#view_2 .kn-filters-nav {
  display: none;
}

Or:

/* Hide filters on all views except some */
.kn-filters-nav:not(#view_1 .kn-filters-nav):not(#view_2 .kn-filters-nav) {
  display: none;
}
2 Likes

Many many thanks! Now I can stop pulling my hair out. :joy:

Hi guys,

This Javascript code does the job automatically, and applies to all (and only) views that have filtering disabled.

$(document).on('knack-view-render.any', function (event, view, data) {
    if (Knack.views[view.key] && !Knack.views[view.key].model.view.filter)
        $('#' + view.key + ' .kn-filters-nav').remove();
})

Enjoy,
Normand

Awesome, thanks! I was pulling my hair out. This worked perfectly.

Anyone know a code to remove the page listing at the top? pages x of x < > (see screenshot)

Screen Shot 2023-03-24 at 9.40.22 AM.png

1 Like

Kim,

Is that something you’d need for all views in all pages, just specific views, for specific Account Roles, or some other use case?

I can customize solutions any solution at will in the KTL. Actually I’ve just integrated that fix I gave you above in the KTL’s next release.

In the meantime, here’s the fix you’re interested in:

$(document).on('knack-view-render.any', function (event, view, data) {
    $('#' + view.key + ' .kn-pagination').remove();
})

This removes the pages navigation for all views, but if you only need a specific view, replace the .any by .view_xxx

Cheers,
Norm

Hi guys,

I’ve updated the code above to prevent errors when doing an inline edit in a table. You should update it in your app also.

Changed this: if (Knack.views[view.key] && !Knack.views[view.key].model.view.filter)

Norm

H Normand! Thanks for your reply. I have been out for a while.

I tried using this but not seeming to get any results with the .any or .view option.

Sorry, I caused a bit of confusion!

For the benefit of all readers, this is what you need to handle both issues, with just one …render.any function:

$(document).on('knack-view-render.any', function (event, view, data) {
    //This is to remove the pagination
    $('#' + view.key + ' .kn-pagination').remove();

    //This is to solve the reappearing filters.
    if (Knack.views[view.key] && !Knack.views[view.key].model.view.filter)
        $('#' + view.key + ' .kn-filters-nav').remove();
})

Yes, you can combine both segments of code together!

Normand

Hi to all,

Some user have reported that the problem where the Add filters button keep coming back actually happens in the Builder. I thought that this was in the App, but it’s not the case.

They set the view to Don’t allow records to be filtered but the setting reverts back by itself to Allow filtering after a few days.

So here’s another solution, less elegant, but still useful:

const removeFilters = ['view_xx', 'view_yy']; //Manually add all the problematic view IDs here.

$(document).on('knack-view-render.any', function (event, view, data) {
    if (removeFilters.includes(view.key)) {
        $('#' + view.key + ' .kn-filters-nav').remove();
        $('.filterCtrlDiv').remove(); //For those using the KTL
    }
})

Normand D.

Thank you Norm, will give it a try… JON