Skip to main content

Hi All,

 

We have a multiple checkbox in one form, user can select multiple checkbox and we want K2 to put all select values into one string with |  as delimite so we can save it to database . Can K2 auto or configure to do something like that.

Example: Form

Question 1 - Check

Question 2 - Check

Question 3 -

Question 4 - Check

 

Can K2 put those selection into one string like this: "Question 1 | Question 2 | Question 4".

 

When we retreat back the string above (Question 1 | Question 2 | Question 4) from the database can K2 parse it into the something like a list so that we can chek the right box.

 

Thanks,

TTN

 

 

Hi TTN,

 

          In your case for data populating purposes, The only thing you need to do is define a data-source along with a Key and a Display property. As you have it in '|' Seprated value in string, this could be done by creating a service method, which will split data and Add it as key and value.

 

Eg:

 

string commaSepratedValue = "Item1| Item2|Item3|Item4";

Split it to array and then add to list using loop

var checkBoxList= new List();

for(var item in commaSepratedValue.Split('|'))

{
checkBoxList.Add(new ListData { Key = item , Name = item });
}
return checkBoxList;

 

 

The above method will return a list of data object with a Key, and a Name property.

Access the service object method and add it as DataSource.


Please Use Choice control and in Display properties do the following changes
Select Display Type as Check Box List
and Delimiter '|'

 

This will return ur output as '|' seprated


Hi Kran,

Can you please walk-through the solution you mention. Its hard to understand how exactly it can be implemented. Thanks for your support.


This will be super easy to acomplish....

 

I suggest:

 

a) Create a param ( 1 or 2 depending if you want Questions and Answers or only answers )

b) Create a Expression to concatenate the Questions / Answers from the Selection Controls

c) Create and Unbound Rule e On change execute Transfer Data put the value of the Expression in the Param ]

 

At the end of the Form The Param will have the value of the selected controls in the Form.

 

Good Luck.


Hi TTN,

 

       Please ignore my previous  reply as I misunderstood for  “When we retreat back the string above (Question 1 | Question 2 | Question 4) from the database can K2 parse it into the something like a list so that we can chek the right box.

 

It’s very easy to implement with Choice control. Please follow the below steps:

  1.  Drag a choice control.
  2.  For properties of Choice control do the following changes:
  • Under Display for Display Type select Check Box and add Delimiter value as ‘|’
  •  

     

     

     


Reply