nigel_mark_bill
Canvas Initiate

k2 view increment counter

Jump to solution

Hi , I have a view with checkboxes for monday,tuesday,wednesday,etc 

 

when i save the view (create the item ), i want a total of the number of days checked . ie if the user selected monday and wednesday i would have the value 2 stored in a data label . How can this be done ? 

Thanks

 

Labels: (1)
0 Kudos
Reply
3 Replies
Prineel
Design Canvas Artiste

Re: k2 view increment counter

Jump to solution

@nigel_mark_bill,

 

I have created a simple way of doing this:
1. I first create an expression using the datalabel (toy can find the "+" in the operator section under operators):
Expression.PNG

 Please note that the datalabel has to be a Number and set to 0.

2. I used a Multi-Checkbox List to populate my data (I used static data)"
Mulit Checkbox list.PNG

 

3. On my button rule, I have a for loop on the Multi-Checkbox List, which will count all of the checked boxes, followed by displaying the result on the label once the button is clicked. I used the "set a control's property" action to do this. See the next screenshot of how the rule was configured.
rule1.PNG

 

4. "set a control's property" configuration:
rule2.PNG

 

I ended it of with disabling the checkbox list control as if the checkboxes would be clicked/unclicked afterwards. 

 

Hope this helps :). If you have any questions or need assistance, please dont hesitate to ask.

 

Kind Regards

Prineel

 

 

View solution in original post

0 Kudos
Reply
nigel_mark_bill
Canvas Initiate

Re: k2 view increment counter

Jump to solution
Hi Prineel , thanks for your complete solution on this , I will try it out . Actually I more or less got by by using a data label and an expression that adds 1 . It works ok , but my solution does not handle the case of the user checking / unchecking multiple times . Thanks a lot , I will give it a go,
0 Kudos
Reply
Prineel
Design Canvas Artiste

Re: k2 view increment counter

Jump to solution

Hi @nigel_mark_bill,

 

I had the same issue. The way I did it, is it calculates everything after the button is clicked that way if the user unchecks/checks before the button is clicked, it does not count it. So it essentially counts the already checked check boxes at the time of the button click.

 

Kind Regards

Prineel

0 Kudos
Reply