Is there a way to detect that a list returns no values?

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

alexmcclune
Ebase User
Posts: 95
Joined: Wed Feb 27, 2013 5:16 pm

Is there a way to detect that a list returns no values?

#1

Postby alexmcclune » Wed Apr 01, 2015 10:21 am

Hi,

We have a Dynamic List that essentially populates addresses. I would like to detect if the list contains no values (null returned from the dynamic list?) so I can display an appropriate message to the user.

Ideally without using a database resource to do the same sort of lookup.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Wed Apr 01, 2015 12:06 pm

You can check the number of entries within the list. Dynamic lists are normally built after all scripts have run, which would be too late in this case. To get around this, you could build the list from within a script, then set field list property When list is built to Never to stop the automatic list building. Code something like this:

Code: Select all

// Build the list
fields.F1.list.buildList();
// Get number of list entries
var n = fields.F1.list.getDisplayValues(false).length;
This means that the list will be built when, and only when, the script executes.
0 x

alexmcclune
Ebase User
Posts: 95
Joined: Wed Feb 27, 2013 5:16 pm

#3

Postby alexmcclune » Wed Apr 01, 2015 2:31 pm

Thanks Jon,

I actually found another workaround using Jquery. The entire purpose was to display a panel/text control if nothing was available in the list. My work around meant handling that in Jquery as well (which is fine if a bit tedious). I just added this to the html element properties

Code: Select all

$('#ddl_html_id option').length; 
Thanks
0 x


Who is online

Users browsing this forum: No registered users and 17 guests