Dynamic List - Multiple Select

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

tom.smith
Ebase User
Posts: 24
Joined: Thu May 09, 2013 2:54 pm

Dynamic List - Multiple Select

#1

Postby tom.smith » Mon Sep 09, 2013 2:54 pm

Hi

I would like to produce a dynamic list from a SQL query, and have the user select multiple items and then do something with the items they have selected - such as build a string variable containing the names of the selected items.

I have built a dynamic list that displays as a list of combo boxes:
- Created the database connection
- Created the dynamic list using native sql
- Added a field to the form
- Set the field properties to have field type of character
- Set field properties to have display type as checkbox
- Set the field properties to use the dynamic list
- Set the field properties alignment to vertical

This produces a very neat vertical list of checkboxes. However, it only allows me to select 1 box at any one time.

Does anyone know of a way of producing a similar list with the ability to select multiple rows?

Thanks

Tom
0 x

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

#2

Postby Jon » Tue Sep 10, 2013 8:57 am

Tom,

Suggest you set up a table containing a list item column and a "select" checkbox column, and then display this in a Repeater Control. It's a bit long-winded but it should work. Here are the steps to do this:

1. Set up a Database Resource with the same SQL as your dynamic list - select the "for use with tables" option.
2. Add this to your form's Business View or set up a new Business View if necessary.
3. Set up a table in your form backed by the Database Resource and import the column into the table from the Database Resource.
4. Add an additional boolean checkbox column to the table.
5. Create a script to issue a fetchTable to the table and run this at some convenient point to load the data - before page event?
6. Display the two table columns in a Repeater Control, set the Repeater's layout to Vertical Box and the Repeater Row layout to Horizontal Box.
7. Set both table columns to only display the editor portion and mark the non-checkbox column (your list item) as display only.

You will then need another script to loop through the table to process the user's selections.

Regards
Jon
0 x

tom.smith
Ebase User
Posts: 24
Joined: Thu May 09, 2013 2:54 pm

#3

Postby tom.smith » Thu Sep 26, 2013 3:24 pm

Thanks for your suggestion Jon, and apologies it took so long for me to get back. I've been working on other things.

I've created the repeater that displays the correct details, which is great. I've not had a lot of FPL scripting experience, can you (or anyone else) point me in the right direction for interring over the table rows?

Thanks

Tom
0 x

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

#4

Postby Jon » Thu Sep 26, 2013 3:50 pm

Tom,

In FPL, you do it like this:

Code: Select all

loop at MYTABLE
  ..
endloop
in Javascript like this:

Code: Select all

var rows = tables.MYTABLE.rows;
while (rows.next())
{
  ..
}
These two syntaxes both do the same thing: they go through the table rows one at a time and set the current row of the table - you could imagine a table with all the rows and you're going through them one by one highlighting each row in turn. Inside the loop code blocks, you can then just refer to a table column and you'll get the value for that particular row e.g. in FPL..

Code: Select all

loop at MYTABLE
  if [ MYTABLE-CHECKBOX_FIELD = 'Y']
     ..
  endif
endloop
in Javascript:

Code: Select all

var rows = tables.MYTABLE.rows;
while (rows.next())
{
  if (tables.MYTABLE.CHECKBOX_FIELD.value)
  {
      ..
  }
}
Regards
Jon
0 x


Who is online

Users browsing this forum: No registered users and 24 guests