Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Implement browse filter

Questions related to using nuBuilder Forte.
Post Reply
Timo
Posts: 219
Joined: Thu Mar 15, 2018 9:26 pm
Has thanked: 1 time

Implement browse filter

Unread post 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.
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4428
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 476 times
Contact:

Re: Implement browse filter

Unread post 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 ('#', '')
)
ricklincs
Posts: 113
Joined: Mon Aug 01, 2011 5:39 pm
Has thanked: 36 times

Re: Implement browse filter

Unread post 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?
kev1n
nuBuilder Team
Posts: 4428
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 476 times
Contact:

Re: Implement browse filter

Unread post by kev1n »

In the context menu, click on e.g. "Object: nuBrowseTitle1". This will copy its ID to the clipbaord.
ricklincs
Posts: 113
Joined: Mon Aug 01, 2011 5:39 pm
Has thanked: 36 times

Re: Implement browse filter

Unread post by ricklincs »

Thanks again Kev1n.
Post Reply