Page 1 of 1

open browse empty

Posted: Thu May 17, 2018 7:11 am
by marc
Hello,

How can I make a browse form not show any records when it is opened?
Records should only be displayed after entering a search string (at least three characters long) and starting the search action.

Re: open browse empty

Posted: Thu May 17, 2018 7:59 am
by admin
marc,

nuBuilder only works the opposite way.


Steven

Re: open browse empty

Posted: Thu May 17, 2018 8:35 am
by toms
Hi,

You can use Hash Cookies in your Browse SQL like this:

Code: Select all

SELECT * FROM YOUR_TABLE WHERE LENGTH('#SEARCH_FIELD#' ) > 2 AND LOCATE('#','#SEARCH_FIELD#') = 0
Explanation: The Hash Cookie is unknown (empty value) when the form is initially opened. Therefore the SQL returns 0 rows ( => empty Browse Table)

And then you need to add some Custom Code -> JS:

Code: Select all

if (nuFormType() == 'browse') {
   $('#nuSearchField').on('change keydown paste input propertychange click keyup blur', function() {
       nuSetProperty('SEARCH_FIELD', this.value );   
  })
}
Explanation: Whenever the text in the Search Field is changed, the Hash Cookie is assigned the value of the search field.
The next time a Search Action is peformed, the Hash Cookie is not empty anymore and the query outputs records, given that the length of the search string is at least 2 characters.

Re: open browse empty

Posted: Sun May 20, 2018 9:27 am
by marc
toms,

Thank you so much - works as expected!

Re: open browse empty

Posted: Sun May 20, 2018 11:51 pm
by admin
.