Solved

k2 view increment counter

  • 20 April 2021
  • 3 replies
  • 103 views

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

 

icon

Best answer by Prineel 20 April 2021, 18:12

View original

3 replies

@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):


 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)"


 


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.


 


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


 


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


 


 

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,

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

Reply