Welcome to the nuBuilder Forums!

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

Search-form with lots of boolean fields

Questions related to using nuBuilder Forte.
Post Reply
hame
Posts: 10
Joined: Fri Oct 28, 2022 2:43 pm
Has thanked: 4 times

Search-form with lots of boolean fields

Unread post by hame »

Hi,
I want to realize a small adress system to manage all the numerous adresses of the office and maybe actions related to the contact (e.g. calls, mails infos). Each address has a lot of fields (boolean) that describe diverse informations (e.g. owns a hotel, owns a restaurant etc.). I'm not sure how to make a very simple form that allows to find specific adresses by selecting some of the named criteria by just clicking/selecting the respective boxes and then "click on find" ...
Thx :-)

Harald
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Search-form with lots of boolean fields

Unread post by kev1n »

I have done something similar just recently ;)

I used a Launch form and placed some filter objects on the left and the results are shown in an embedded iFrame. Did you think of something like this?
search_form.png
You do not have the required permissions to view the files attached to this post.
miasoft
Posts: 156
Joined: Wed Dec 23, 2020 12:28 pm
Location: Russia, Volgograd
Has thanked: 32 times
Been thanked: 7 times
Contact:

Re: Search-form with lots of boolean fields

Unread post by miasoft »

Yes, it would be nice to have such a Query-form. Or use an already existing Edit-form in Query mode
Wbr, miasoft.
hame
Posts: 10
Joined: Fri Oct 28, 2022 2:43 pm
Has thanked: 4 times

Re: Search-form with lots of boolean fields

Unread post by hame »

kev1n wrote: Fri Nov 11, 2022 3:56 pm I have done something similar just recently ;)

I used a Launch form and placed some filter objects on the left and the results are shown in an embedded iFrame. Did you think of something like this?

search_form.png
Hi Kev1n,

yes - that's nearly the solution. I will try to tell it my nubuilder :-).l

Harald
hame
Posts: 10
Joined: Fri Oct 28, 2022 2:43 pm
Has thanked: 4 times

Re: Search-form with lots of boolean fields

Unread post by hame »

Hi all,
are there maybe already similar nubuilder projects in use or on the run ?
Thanks!
Harald
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Search-form with lots of boolean fields

Unread post by kev1n »

Basically, you can check out the demo at https://demo.nubuilder.cloud ( nuBuilder Objects -> Run iFrame (Form) )
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Search-form with lots of boolean fields

Unread post by kev1n »

Let me know if you need more information
miasoft
Posts: 156
Joined: Wed Dec 23, 2020 12:28 pm
Location: Russia, Volgograd
Has thanked: 32 times
Been thanked: 7 times
Contact:

Re: Search-form with lots of boolean fields

Unread post by miasoft »

kev1n wrote: Mon Nov 14, 2022 12:34 pm Basically, you can check out the demo at https://demo.nubuilder.cloud ( nuBuilder Objects -> Run iFrame (Form) )
How to reset (cancel) the filter and return to the full list?
Wbr, miasoft.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Search-form with lots of boolean fields

Unread post by kev1n »

This is how I set up my search form:

1. All filter fields on my form have an attribute called "filter-field". This makes it easier to clear all as you will see in step 3.
filter_field.png
2. In the form's Custom Code:

Code: Select all

// Add an event listener for all filter fields and if the user pressed the "Enter" key, apply the search
$("[filter-field]").each(function() {

    $(this).enterKey(function(e) {
        applySearch();
    });

});

function applySearch() {

    var frame = $("#your_iframe_object_id")[0].contentWindow; // <--- Replace your_iframe_object_id with your iframe object id

    // Set Hash Cookies (HK) for all filter fields:

    // Example: Set HKs for Text fields
    frame.nuSetProperty('filter_adr_last_name', adr_last_name.value);
    frame.nuSetProperty('filter_adr_first_name', adr_first_name.value);
    frame.nuSetProperty('filter_adr_company', adr_company.value);

    // Set HKs for Boolean fields
    frame.nuSetProperty('filter_adr_active', nuGetValue('adr_active') ? '1' : '');

    frame.nuGetBreadcrumb();

}
3. Add a "Reset filter" button with an onclick event:

Code: Select all

$("[filter-field]").val(''); // empty all filter fields
applySearch();

4. iFrame Browse SQL:

Code: Select all

SELECT * FROM #TABLE_ID#
5. iFrame BB (Before Browse) PHP Code:

Code: Select all

$filter = ' AND (1 = 1) ';

setFilter($filter, 'filter_adr_first_name', 'adr_first_name');
setFilter($filter, 'filter_adr_last_name', 'adr_last_name');
setFilter($filter, 'filter_adr_adr_company', 'adr_adr_company');
setFilter($filter, 'filter_adr_active', 'adr_active');

function setFilter(&$filter, $filterName, $columnName) {
    $value = nuGetProperty($filterName);
    if ($value != '') $filter .= " AND $columnName LIKE '%$value%' ";
}
$create = "CREATE TABLE #TABLE_ID# ";

$select = "

SELECT 

    address_id,
    adr_first_name,
    adr_last_name,
    adr_company,
    adr_active

FROM address 

WHERE (1 = 1)  -- your where clause, if there is any

" . $filter;

// To output the SQL to nuDebug Results:
// nuDebug($select);
nuRunQuery($create . $select);
 
You do not have the required permissions to view the files attached to this post.
Post Reply