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
Dynamic List - Multiple Select
Moderators: Jon, Steve, Ian, Dave
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
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
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
-
- Ebase User
- Posts: 24
- Joined: Thu May 09, 2013 2:54 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
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
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
Tom,
In FPL, you do it like this:
in Javascript like this:
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..
in Javascript:
Regards
Jon
In FPL, you do it like this:
Code: Select all
loop at MYTABLE
..
endloop
Code: Select all
var rows = tables.MYTABLE.rows;
while (rows.next())
{
..
}
Code: Select all
loop at MYTABLE
if [ MYTABLE-CHECKBOX_FIELD = 'Y']
..
endif
endloop
Code: Select all
var rows = tables.MYTABLE.rows;
while (rows.next())
{
if (tables.MYTABLE.CHECKBOX_FIELD.value)
{
..
}
}
Jon
0 x
Who is online
Users browsing this forum: No registered users and 13 guests