Clearing filters on loading a table
I use this snippet to clear the filters for a table (all). It is under a button.
ui.openTableOld?null:ui.openTableOld=ui.openTable;
ui.openTable = function(...arg) {
ui.openTableOld(...arg);
document.querySelectorAll('#exColumnFilter-close')?.forEach( button => button.click())
}
}#;
openTable("PROJECTS", "ALL")
Is it possible to use it somehow within a view? For example, in PROJECTS which loads with cleared filters I might have a view of EQUIPMENT used for that project. It would be handy to be able to load PROJECTS clear of filters as well as any views associated with PROJECTS
19 replies
-
Hello Alan,
I am currently on vacation without a computer. It’s a bit of a detox cure .
I think it should be possible. You need to check which function is called when a view is selected (openView?).
It would also be necessary to ask Ninox to fix the bug where, when reopening a table that previously had a filter, the filter is applied but not visible in the filter input field.
-
Hi Alan,
I’m back from vacation and I’ve just looked into what can be done. I found this script that can be executed from a button:
It removes the filters from the view field named fieldName and refreshes the display. The code needs to be executed when the form is opened.
#{ let fieldName = 'List of customers'; ui.getCurrentEditor().currentTab.components.find( c => c.field.caption == fieldName && c.field.base == "view")?.query.cols?.forEach( cl => cl.filter=null); ui.getCurrentEditor().currentTab.nodeChanged(); }#
-
Very Cool... You should have more vacations - it clearly inspires you !
-
Just tried this out to clear filters - Really is a handy bit of code. Thanks
Here is another idea. Kind of the above but in reverse. Would it be possible to have a button with code that applies A-Z or Z-A on a column. Let's say we have a Date field or Invoice number field. By clicking a button the Date field (FieldName) sorts the column A to Z and another button for Z to A.
I realise one can do this in a column directly but a button would be a much 'smoother' approach.
Content aside
-
1
Likes
- 4 mths agoLast active
- 19Replies
- 131Views
-
7
Following