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!
Thanks in advance.
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Implement browse filter
Implement browse filter
You do not have the required permissions to view the files attached to this post.
-
- nuBuilder Team
- Posts: 4428
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 74 times
- Been thanked: 475 times
- Contact:
Re: Implement browse filter
Hi Timo,
To apply a filter to a browse column using
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:
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
To see a working example, inspect other forms in your nuBuilder system that use
3. Update the SQL in the Browse Object
To handle the filtering correctly, include this WHERE clause in your SQL:
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
});
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()
});
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
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?
-
- nuBuilder Team
- Posts: 4428
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 74 times
- Been thanked: 475 times
- Contact:
Re: Implement browse filter
In the context menu, click on e.g. "Object: nuBrowseTitle1". This will copy its ID to the clipbaord.