restricting values of dropdown attached to dynamic lists

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

HarryDeBoer
Ebase User
Posts: 118
Joined: Tue Oct 23, 2012 7:01 am
Location: The Netherlands

restricting values of dropdown attached to dynamic lists

#1

Postby HarryDeBoer » Wed Jun 05, 2013 8:12 am

LS

Can anyone show me what would be the proper way to restrict the values in a dropdownbox attached to a dynamic list. I have a dynamic list but depending on values in a config table some values must not be shown in the dropdown.

list: 1,2,3 and 4

in the config it says that (this user) may only see 1 and 3.

Regards, Harry
0 x
Kind regards,

Harry

User avatar
jig
Ebase User
Posts: 30
Joined: Sun Oct 09, 2011 10:16 am
Location: UK

#2

Postby jig » Wed Jun 05, 2013 9:36 am

Hi Harry,

If the list is build from a database table, I would recommend a dynamic WHERE clause using '&&QUERY' principle.

Then at runtime, you can substitute the '&&QUERY' with something like USER_ID='Ben' so that the SQL looks like...
Select * from TABLE1 WHERE USER_ID='Ben'

Hope this helps!

Regards
Jignesh
0 x
Regards,
Jignesh

Jignesh Vaducha, MSc, MCA
Mobile: +44 (0) 77 325 47 112
Telephone: +44 (0) 1462 488 311
Email: jignesh@schnellsolutions.com

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

#3

Postby Jon » Wed Jun 05, 2013 9:42 am

Topic moved to Application Development forum.

You can restrict list entries by creating a custom list from the dynamic list and only adding those entries you want to. Here is an example that takes out all list entries beginning with "B".

Code: Select all

// First build the dynamic list
fields.MYFIELD.list.buildList();
// Now get the list values
var dynamicListValues = fields.MYFIELD.list.getDisplayValues(false);
// Create a custom list and attach it to the field
var customList = fields.MYFIELD.createCustomList();
// Loop through the dynamic list entries and take out those we don't want
for each (var entry in dynamicListValues)
{
  if (entry.charAt(0) != "B")
  {
    customList.add(entry);
	}
}
You should also set the "When list is built" property to "Never" for the form field. This stops the system building the list automatically - it's now going to be built only when you invoke the buildList() method. This approach works fine if you just want to build the list once. But it won't work if you need to build the dynamic list more than once - this is because the dynamic list has been replaced with the custom list and the build will fail second time around.
0 x


Who is online

Users browsing this forum: No registered users and 6 guests