Taffy_Lewis
Novice

Displaying Multi-Select Values saved in a database

So, I have created a K2 entry form that uses a multi-select controls.  It saves the values with the default ";" delimited.  What is the control that you use to display the values to the user, show to the user in a List View.  I'm guessing its the List Display.  Can someone point me to where I can find out how to do this?

 

So, I've been looking around all morning and have not found anything????  This leaves me with the thought that there is no K2 control that will display a saved multi-select value???   Does this mean that I would have to create a function that parses the field and sends the values back to K2.  That doesn't make sense??/

0 Kudos
Reply
9 Replies
tin
Apprentice

Re: Displaying Multi-Select Values saved in a database

If this is an item view, I believe you could use a "Choice" control but with Display Type property of "Check Box List", this would save and load data with the delimited semi-colon structure mapped to your Smartobject data source.

0 Kudos
Reply
Taffy_Lewis
Novice

Re: Displaying Multi-Select Values saved in a database

Didn't work, but thanks for the suggestion Tin!

 

Taffy

0 Kudos
Reply
Andrew_Blinco
Apprentice

Re: Displaying Multi-Select Values saved in a database

Hi Taffy

 

You can use the Choice checkbox control, but you must first set the data source of the control and then transfer in the delimited string to set the checked values. The control will display all the values from the datasource as checkboxes and then check the values that you transfer in.

 

Example:

 

On your entry form you have a Choice control with the datasource set to the list method of a  smartobject with properties ID, Name. User checks some boxes and then saves. The selected ID values are stored in another smartobject as a delimited string.

 

To display the checked values, configure a Choice control using the same data source as above. Then execute a Read smartobject method on the smartobject where you saved the values, to retreive the saved values (delimited string) and transfer them to the Choice control. 

 

If you want to display only the selected values, then I suggest you look at a way of saving the selected values a separate row in a smartobject (e.g. use a stored procedure to parse the delimited string and save a new record for each item).

 

 

0 Kudos
Reply
Taffy_Lewis
Novice

Re: Displaying Multi-Select Values saved in a database

Andrew,

 

The "Choice Checkbox" control.  I don't seem to have that.  Is it in the underground.  I have a "choice" control and a "check box list."  Neither worked for me in the way you described.

 

Taffy

0 Kudos
Reply
tin
Apprentice

Re: Displaying Multi-Select Values saved in a database

I believe a Choice control will have 3 display options:


 


- display as drop-down list


- display as check box list


- display as radio button list


 


And by default will save and load data from the backends with a semicolon delimiter (can be changed to another character if needed).


 


2043i52FF5BAC3BBA13B9.png

Reply
Andrew_Blinco
Apprentice

Re: Displaying Multi-Select Values saved in a database

Hi Taffy

 

What control are you using to save the multi-select values on your entry form? 


As explained by tin you can use the Choice control (part of the SmartForms Control Pack) and set the display type to check box list.

Reply
Taffy_Lewis
Novice

Re: Displaying Multi-Select Values saved in a database

Thanks for the reply Andrew, big-ups to you and Tin for your input.  I'm using a multi-select control on the entry form.  When I call the smart-object and have the multi-select on the update screen it loads the saved data fine.  Its on the list view for multiple records view that this is not loading (Drop-Down List; Check Box List; Radio Button List) do not work.   :(

 

 

0 Kudos
Reply
tin
Apprentice

Re: Displaying Multi-Select Values saved in a database

Currently, out-of-the-box, in a list/editable listview; I do not believe you can display a control in the "Display" section, it seems to only work in the "Add/Edit" mode of a list item in a editable listview.


 


2050i8B01102938006CEA.png


Add/Edit item mode


 


2047iA83C459F5C95E58D.png


During Edit Mode in Editable List View


 


 2049iA03F135299926A38.png


During Add Mode in Editable List View

0 Kudos
Reply
Taffy_Lewis
Novice

Re: Displaying Multi-Select Values saved in a database

Yes Tin, correctamundo, there are no controls that I can use that can take the saved values from the multi-select and display the values in a list view, there in, was the problem.  :)

 

For anyone reading this or who have the same problem, my solution was a 3 step SQL Solution.

 

I created another smart-object method that uses t-sql syntax that

1. call a nested select statement that pulls the delimited values from the field

2. call a custom sql function that split the values from the delimiter

3. used the t-sql STUFF function to stuff the values into an alias column that I returned within the new smart-object method

 

Taffy

Reply