Page 1 of 1
Implement browse filter
Posted: Thu Jul 17, 2025 2:04 am
by Timo
Hi all,
I'd like to implement a filter for a Browser object similar to the one in nuBuilder 4.8, where you can filter records directly above the column headers.
I haven't been able to find any documentation or forum posts explaining how to do this.
Any pointers, examples, or directions would be greatly appreciated!
filterx.png
Thanks in advance.
Re: Implement browse filter
Posted: Tue Jul 22, 2025 6:47 am
by kev1n
Hi Timo,
To apply a filter to a browse column using
nuAddBrowseFilter()
, follow these steps:
1. Get the Column ID
Right-click the column header in the Browse view and copy its
column ID (e.g.
nu5bad6cb377a01b0).
2. Add JavaScript to the Form
Go to
Form > Custom Code > Browse Field and add one of the following code snippets:
Static List Example
Use this if you want a fixed list of values:
Code: Select all
const myList = [
["", ""],
["nuDate", "nuDate"],
["nuNumber", "nuNumber"],
["nuScroll", "nuScroll"],
["nuAutoNumber", "nuAutoNumber"]
];
nuAddBrowseFilter('nu5bad6cb377a01b0').nuSearchablePopup({
items: myList
});
Dynamic List Example
If you want the list to be generated dynamically:
In
BB - Before Browse (PHP), retrieve the filter items using MySQL. Then use
nuAddJavaScript()
to pass a JavaScript function that returns those items to the form.
Code: Select all
nuAddBrowseFilter('nu5bad6cb377a01b0').nuSearchablePopup({
items: myList()
});
To see a working example, inspect other forms in your nuBuilder system that use
nuSearchablePopup()
.
3. Update the SQL in the Browse Object
To handle the filtering correctly, include this
WHERE clause in your SQL:
Code: Select all
WHERE (
your_column = '#nu5bad6cb377a01b0_filter#'
OR LEFT('#nu5bad6cb377a01b0_filter#', 1) IN ('#', '')
)
Re: Implement browse filter
Posted: Fri Aug 22, 2025 1:32 pm
by ricklincs
After update how do I find the Column ID, now in browse I right click on the column header and instead of seeing an id like nu5bad6cb377a01b0 I see nuBrowseTitle1?
Re: Implement browse filter
Posted: Fri Aug 22, 2025 2:03 pm
by kev1n
In the context menu, click on e.g. "Object: nuBrowseTitle1". This will copy its ID to the clipbaord.
Re: Implement browse filter
Posted: Fri Aug 22, 2025 2:05 pm
by ricklincs
Thanks again Kev1n.